Pages

Tuesday, March 27, 2012

Vanity Url using Url Rewriting in asp.net 4.0

Url rewriting can be accomplish via two methods:
1.HTTP module 
2HTTP handler
let us discuss using HTTP handler:


Since SEO comes into consideration it becomes the part of web development. These days every website being developed should be optimized to some extent so it could get crawled by Search Engines.Its advisable that you should take care of your URL’s rather than showing them in a raw format make them readable by user as well SEO friendly.
URL is the important part that search engines want to take a look before they crawl the pages of your website. There are enormous open source libraries and ISAPI filter available that provides support to help you rewriting your URLs. The SEO and url rewriting is now taken into account and is introduced a supported extension for IIS 7.0/7.5 by providing URLRewriterExtension. But here we’re going to discuss how you can rewrite you URL in your Asp.net website with just 3 steps.

1. Create a Route path entry in RouteCollection
First of all add below code your to you Global.asax file. you can add as many route as you want to the RouteCollection object.

image




2. Create a class specific to the particular section that implements the IRouteHandler interface
to handle the incoming Route and receiving the data from the URL
 
image

3. Finally get into the Asp.net web form and process the request
span style="font-family: 'Courier New';">protected void Page_Load(object sender, EventArgs e)
 {
 int catid = Convert.ToInt32(HttpContext.Current.Items["catid"]);     
 var product = awe.Products.Where(item => item.ProductSubcategoryID == catid);             GridView1.DataSource = product;

 GridView1.DataBind(); 
}

sources: 
http://msdn.microsoft.com/en-us/library/ms972974
http://somenewkid.blogspot.com/2006/05/charlie-has-cool-urls-part-1.html

Download Source Code

Tuesday, January 31, 2012

Asp.net development server failed to start listening on port xxxx.

 I got the message:

Asp.net development server failed to start listening on port xxxx.
Error Message: only one usage of each socket address is normally permitted .

Search on net, people all think that if the port is not available, just change the port for the web development server and it will work. Based on this theory, I changed the port number of the ASP.NET web development server, and it worked for me. I typed the steps here…
Go to the Solution Explorer in Visual Studio, click on the web site application, hit ‘F4′ key to bring up the application’s property window. In this property window, set ‘Use Dynamic Port’ to ‘False’, and you will be able to set the Port number to a number other than the previous port number.
See this official MSDN document on how to change the port number for the ASP.NET development server:
http://msdn.microsoft.com/en-us/library/ms178109(VS.80).aspx

Wednesday, October 19, 2011

Query to find non unique column from a table

I have a users table that has over 10,000 registered users (from a database that I've inherited). The original code allows for multiple registrations with the same email address which I want to eliminate. 

Thursday, October 13, 2011

asp:XXXXX is not a known element. This can occur if there is a compilation error in the web site.

Problem occurred when I re-install Visual Stdio 2005...after digging for awhile i find the solution. Changing tag prefix did the job.
<webconfig

<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</controls>
</pages>
change tagPrefix="asp" to tagPrefix="ajax" or whatever prefix you want. Then change your existing ajax control tags to use that prefix instead. E.g. <asp:UpdatePanel...> becomes <ajax:UpdatePanel...>

Monday, September 12, 2011

Database Connectivity Class(layered)

This is a custom Class, Tested and error free. Download it and copy and paste in your solution within Appcode folder. and call the methods via its class name .
here is the Download link: Download
hope this will help you.