Sunday, June 19, 2011

automatically detect the language set in the user's browser

Q. How can a asp.net page automatically detect the language set in the user's browser ?
Automatic detection of the language preference of the user as set in his browser
In your web.config file, you need to set the following globalization tag with the values that are presented below:
<system.web>
   <globalization
          uiCulture="auto"
          culture="auto"
          enableClientBasedCulture="true" />
</system.web>

New features in .Net 4.0

1. ASP.NET 4.0 comes with a new option for compressing the Session data with Out Process Session mode(mode=StateServer). To enable this functionality, we need to add “compressionEnabled=”true” attribute with the SessionMode in web.config.
image
When Compression mode is enabled in web.config, ASP.NET compresses the serialized session data and passes it to session storage and while retrieving same deserialization and decompression happens in the server side. ASP.NET 4.0 used System.IO.Compression.GZStream class to compress the session mode.

2. We can programmatically change Session State Behavior when required as below:


 //The Session State behaviour can be any of: Default,Disabled,ReadOnly,Required based on the requirement.

3.
HttpContext.Current.SetSessionStateBehavior( System.Web.SessionState.SessionStateBehavior.Default)

Monday, May 2, 2011

readonly properties

There is nothing like readonly properties because readonly keyword is applied only to field members. and readonly members are initialized only in the constructors.

We can have properties which has only get block and no set block which allows only to return the values but not set or assign the value.

Ex:
private int _i=5;
public int i //this property allows to get the value of _i variable but we cant set the value of _i.
{
   get
   {
      return _i;
    }
}

Monday, April 25, 2011

visual studio crashes when adding connection to online database from server explorer.

visual studio crashes when adding connection to online database from server explorer.
I encountered this problem recently and i found that the reason was that my computer c drive has less space(less than 150 mb). i deleted few files from c drive then it was working fine.

Saturday, April 23, 2011

silverlight exception

when i was trying to get the data from a webservice in my silverlight project i got the following exception. It was working few minutes back but when i restarted my visual studio project i got the exception.
An error occurred while trying to make a request to URI 'http://localhost:1285/WebServices/LoginService.svc'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details.

solution: I tried adding the clientaccesspolicy.xml file which is used to access webservice if it is hosted on some other server. but still the same problem. then  I noticed that the random port VS2010 was using earlier had changed from what it was using now(as i restarted my visual studio).  I looked at my service references and it was using the old port number in the service definitions.  I updated the new visual studio port number or you can also delete the service references and then recreate them and everything will work fine - I then checked the web.config and service refs and they now have the new port number.

Friday, April 22, 2011

Time management

http://richgrad.com/powerful-time-management-strategies-by-randy-pausch/This link has a very good video on Time Management.

Click Here to watch the time management video.

Saturday, April 9, 2011

mysql error: 150

MySQL error no: 150.

I got this error when the primary key column was not unsigned but foreign key column was checked signed. so make sure that both primarykey column in parent table and foreign key column in child table both datatype, range match properly.