Wednesday 19 March 2014

Logging Tools Log4Net vs ELMAH

Both needs configuration files.

Log4Net

  • Simple general purpose logging tool.
  • Easy to integrate.
  • Creates text file.
  • Log levels: DEBUG, INFO, WARN, ERROR, FATAL.

Pros
  1. Highly configurable logging framework.
  2. Best used by calling explicitly through code.
  3. Can implement exception handling with handlers.
  4. Output: file, console, email.
  5. Thread-safe.
  6. Will not throw unexpected exceptions at run-time potentially causing application to crash.
Cons
  1. Not reliable.

ELMAH (Error Logging Modules And Handlers)

  • Logging and notification of unhandled exceptions.
  • Since it handles all unhandled exceptions, log level is always ERROR.
  • Ability to display a  list of errors and the details of a specific error from a web page.
  • View exceptions via different mechanisms (SQL, RSS, Twitter, files, email etc).
  • Customize filtering logic.
  • Custom HandleError with ELMAH Attribute in ASP.NET MVC

Pros
  1. Good for reporting overall errors and unhandled exceptions.
  2. No change in application code for implementing ELMAH.
  3. Few configuration change.
  4. Good solution for YSOD (Yellow Screen Of Death).

Cons
  1. Can go complex.
  2. Only used for exception messages.


Log4Net - ELMAH - Appender
  • Communicate with ELMAH library on behalf of Log4Net.
  • Adds the ability to make Log4Net entries routed to ELMAH

Thursday 13 March 2014

Remove first character from string C#

Use substring() method.

string str = "/a.txt";
str = str.substring(1);


Output

a.txt

URL querystring with multiple parameters not working - Browser compatibility Issue

When passing multiple parameters as query string, the redirection will work properly in Internet Explorer. This is because the special character '&' is escaped automatically.

But in Mozilla, Chrome it will not work.
www.example.com/controller/action?a=1&b=2

In order to work we need to escape the ampersand special character using Razor syntax @Html.Raw(string).

www.example.com/controller/action?a=1&b=2


iOS

Cannot install applications because the certificate is not valid. - iOS 7.1 Enterprise App

Is it rediculous? May be or not. Might be for more security.

Any way this error is showing in iOS 7.1. When we see this in first time we will get confused.

Install error
Error

The above alert is coming while installing applications in iOS 7.1.


Analysis

From iOS 7.1 Apple is enabled additional security feature, that the enterprise apps manifest file (.plist) to be served with HTTPS. Only the .plist file needs to be in HTTPS format.

Solution


Since the URL for the plist file must be in HTTPS format you need to obtain a valid SSL certificate.
In IIS we can create self-signed certificate which will not work for creating plist url.

If you are not having any valid SSL certificate in your server, you can upload plist file in dropbox and create a https format url for plist in order to work in iOS7.1.

In dropbox the link created will be

https://www.dropbox.com/s/glwllqmnwutl2rm/test.plist

Change www.dropbox.com to dl.dropboxusercontent.com, and add to the url.So it will become

https://www.dl.dropboxusercontent.com/s/glwllqmnwutl2rm/test.plist

Add this HTTPS format to the OTA (Over The Air) link, it becomes:

itms-services://?action=download-manifest&url=https://www.dl.dropboxusercontent.com/s/glwllqmnwutl2rm/test.plist










Saturday 1 March 2014

How to check .NET Framework version installed in your PC

For checking which .NET Framework is installed in your PC, follow the below steps

Steps:
  1. Click on Start.
  2. Type regedit in  Search and files area.
  3. You will see Registry Editor popup window.
  4. Go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework.
You will see different version which are already installed.
Check the latest version installed in your PC. :)