Wednesday, October 26, 2016

How to create a dictionary like mapping in web.config file in .Net Development

it is quite convenience to setup a dictoniary mapping in the configuration file. so we did not have to make any code change if we have to add more mapping in the future.


it is okay to use the appSettings to performance this task. However it is better to create a new section and store those mapping. it is quute easy to complete this approach.

step one. create a new section name under the configSections tag


<configSections>
    <section name="PdfFileMap" type="System.Configuration.NameValueFileSectionHandler, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  </configSections>

step two. set up the new sections in the web.config file

<PdfPrintMap>
    <add key="Doc1" value="Doc1.pdf" />
    <add key="Doc2" value="Doc2.pdf" />
    <add key="Doc3 value="Doc3.pdf" />
    <add key="Doc4" value="Doc4.pdf" />
  </PdfPrintMap>

setp three implement a method to access the section and retrieve the values by providing the section name, and the key. as a result, when we have the key, we can directly load the value.

   public static string GetCustomSectionValue(string sectionName,string key)
        {
            NameValueCollection section = (NameValueCollection)ConfigurationManager.GetSection(sectionName);
            if (section != null)
            {
                return section[key];
            }
            return string.Empty;
        }

Wednesday, October 19, 2016

HTTP vs HTTPS binding in Dynamic AX WCF service configuration

We might think that it is quite easy to swtich from HTTP to HTTPS in the WCF Service binding configuration, as we just simply replace the HTTP in http:// WCFServiceServer/WCFServce.svc  to HTTPS https:// WCFServiceServer/WCFServce.svc

when you launch the app and call the wcf service, you will encounter an exception during the service consumption.

it is little difference between the HTTP vs HTTPS binding in DAX WCF service configuration. this is better approach to have two configurations enable in the web.config file. I highlight the difference in bold.

one is the basicHttpBinding for http link

<basicHttpBinding>
        <binding name="reqReplyEndpoint">
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Windows" />
          </security>
        </binding>
        <binding name="DaxBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
          receiveTimeout="00:01:00" sendTimeout="00:01:00" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Windows" />
          </security>
        </binding>
      </basicHttpBinding>


another is basicHttpsBinding for https link

      <basicHttpsBinding>
        <binding name="SecurereqReplyEndpoint">
          <security mode="Transport">
            <transport clientCredentialType="Windows" />
          </security>
        </binding>
        <binding name="DaxSecureBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
          receiveTimeout="00:01:00" sendTimeout="00:01:00" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="Transport">
            <transport clientCredentialType="Windows" />
          </security>
        </binding>
      </basicHttpsBinding>


Wednesday, October 12, 2016

How to conditional display the text of button in AngularJS

If you are a C# developer, you will easily understand the syntax. it is same with ? : Operator
 
?: Operator

<button type="submit" ng-click="MyButtonClick()"><span>{{isConditionMeet ? 'True Condition Text' : 'False Condition Text'}}</span></button>


Deployed Sharepoint Add-On (former sharepoint App) to Production

when we move sharepoint Add-On to the production, we try to use the package in the QA and uploaded it to the app store in the production enviroment.

After create a page, and added the add-on via the web part on the host page. save the change, then reload the page, but web app is reference to the QA host.

we must repack the sharepoint with the live URL of the web app, so that we can have the sharepoint Add-On with corrected path to the Live Web Application.