K-MUG bags the Microsoft Community Impact Award 2010
Kerala Microsoft User Group (http://k-mug.org) received the best developer user group in India as part of the Microsoft Community impact award 2010 announced by Microsoft yesterday. Microsoft Community IMPACT Awards recognizes the great work done by members of the technology community in India to drive awareness, readiness and excitement about Microsoft technologies among the broad Developer and IT Professional ecosystem in INDIA. Award selection criteria includes the various user group activities (such as technical sessions, trainings, developer conferences etc) conducted by the community in last year.
You can get more information about this from here : K-MUG Bags the Microsoft Community impact Award 2010.
Implementing Paging in SQL Server 2005 Stored Procedures
Normally for implementing Paging in Grid View, we enable the Paging property in GridView and will write code in the PageIndex Changed event. But the problem with this approach is it will fetch all the data from Database for Paging, will result wastage of network bandwidth and resources, also affect in the Page Performance. In SQL Server 2005 Microsoft introduced a new concepts called Row_Number() and Derived Table with the help these two we can move the Paging logic to Database instead of ASP.Net web forms. This concept also works with custom paging implementations for DataList or Repeater controls.
CREATE PROCEDURE usp_GetContacts (@Page INT, @RecsPerPage INT) AS SELECT tblContacts.[Name], tblContacts.[IsParent] FROM (SELECT ROW_NUMBER() OVER(ORDER BY [ID]) AS RowNumber, [Name], [IsParent] FROM [TreeView].[dbo].[Contacts]) tblContacts WHERE RowNumber > @RecsPerPage*(@Page) AND RowNumber <= @RecsPerPage*(@Page+1)
In this code we are creating a Column called “RowNumber”. And we are comparing the input parameters with the derived table tblContacts.
Thanks to Aneesh / Prasanth for their valueable suggestions and comments.
Deploying WCF Service in IIS : no svc MIME Type
Few days back I developed a Silverlight application, which uses a WCF Service to communicate to Database. After the development when I tried to deploy the WCF Service on my IIS, it was displaying some error like
Server Error in Application “Default Web Site/SampleApp”
HTTP Error 404.3 – Not Found
Description: The page you are requesting cannot be served because of the Multipurpose Internet Mail Extensions (MIME) map policy that is configured on the Web server. The page you requested has a file name extension that is not recognized, and is not allowed.
Error Code: 0×80070032
Notification: ExecuteRequestHandler
Module: StaticFileModule
Requested URL: http://localhost:80/SampleApp/CoreService.svc
Physical Path: C:\Users\Documents\Visual Studio 2005\Projects\SampleApp\SampleApp\CoreService.svc
Logon User: Anonymous
Logon Method: Anonymous
Handler: StaticFile
I tried IIS MimeTypes and I couldn’t found an application mapping for SVC file. After doing some searching I found the fix. It is happening because of not registering the WCF in IIS. You can resolve this using WCF Installation utility which comes with .Net Framework 3.0. Run the command prompt as Administrator, go to the Windows Communication Foundation folder in c:\Windows\Microsoft.NET\Framework\v3.0\ folder. Execute the servicemodelreg.exe with -i or /i switch. After the installation try reloading the Page. It will fix this issue.
Convert string to enum
Sometimes we may need to read a Config value using ConfigurationSettings.AppSettings and assign it to a Enum. This function helps to convert a string to Enum.
/// <summary>
/// Function to retrive Enum value by giving the corresponding string value.(This method is case sensitive)
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="value">The value.</param>
/// <returns>Enum value</returns>
public static T ToEnum<T>(string value)
{
//This method will throw error if the case of the value is different from the
//enum value.
if (Enum.IsDefined(typeof(T), value))
{
return (T)Enum.Parse(typeof(T), value, true);
}
throw new ArgumentException("Value doesn't exists in the Enum");
}
System.InvalidOperationException – The length of the string exceeds the value set on the maxJsonLength property.
Yesterday I got a problem from one of my friend; he is getting a Javascript exception from some Ajax Page methods. The exception occurred when he tried to return a very long string from web method. The exception was like this.
Error: Sys.Net.WebServiceFailedException: The server method ‘WebServiceMethod’ failed with the following error: System.InvalidOperationException– Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.
After doing some searching we resolved it. You can resolve this error by modifying the web.config file, and add / modify the Configuring JSON Serialization.
<configuration>
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="5000"/>
</webServices>
</scripting>
</system.web.extensions>
</configuration>
The default length is 102400.
You can get more information about this from MSDN : http://msdn.microsoft.com/en-us/library/bb763183.aspx
