ASP.NET Web Forms URL Rewriting capability - asp.net

I have a very simple question, rather I am just curious.
I have about 2000 pages of the url format somewebsite.com/ShowProduct.aspx?ID=223 . This particular url has a page title as 'Walking sticks for elders made from durable steel'.
Can I use URL Rewriting to convert this to a url like somewebsite.com/walking-stick-for-elders ? Also will I have do it dynamically for 2000 pages or is there any expression that can be used?

You need to have some thing which uniquely indentifies URLs just like Stackoverflow does it.
ASP.NET Web Forms URL Rewriting capability
See this question URL - Where from URL you get its for question then there is a question id and then description. I suggest you do the same.
If you are using ASP.NET 4.0 or higher version then you can do that type of URL routing very easily.
Like from this URL - http://weblogs.asp.net/scottgu/url-routing-with-asp-net-4-web-forms-vs-2010-and-net-4-0-series
There is also a asp.net friendly URL package form where you can write URls.
http://www.hanselman.com/blog/IntroducingASPNETFriendlyUrlsCleanerURLsEasierRoutingAndMobileViewsForASPNETWebForms.aspx
RouteConfig.RegisterRoutes(RouteTable.Routes);

If each product name is unique and stored inside the database you can easily route each SEO friendly URL to productID without manually inputing a new route in the Routing table.

Related

URL issue in NopCommerce dot(.) is not accept in URL

I'm working on NopCommerce Project and
I want a URL like : www.youstore.com/category.cfd
but in SEO I entered the category.cfd but it does not accept the dot(.) in URL it will automatically remove dot(.) while i'm saving the SEO name.
Please, help me out for that
Dots in this kind of urls are not supported by nopcommerce, all the urls of products and categories are cleaned to keep seo friendly urls.
You can tweak nopcommerce to allow dots (changing the source code or changing the UrlRecord table values) but when you add a dot to the url, the .Net extensionless handler used to process mvc request will not catch that request anymore, that means that you will recieve a 404 error because the web server will be searching for a phisycal file.
If the dot is mandatory by your requirements you can use the url rewrite module at iis level and rewrite all the urls (for example all the urls finished with .cfd) removing the dot, so internally you will have www.youstore.com/categorycfd or www.youstore.com/category, this can be tricky because you need to keep dots for file paths as images.

changing page address format

I create a website with ASP.NET web form and I used URL friendly to shape my URLs , by URL friendly my URLs change but not enough for example one of my page "تور استانبول" URL after changing by URL friendly is Domain.com/tours/تور-استانبول/استانبول/1 but I want Domain.com/تور-استانبول/استانبول/
please note that I don't want to query on sql to rewrite to my page and also I don't want to create static page and because my pages are dynamic I can't write all of them in web config file
please help me in this case
Hamid, you can use asp.net routing. The following link contains explains how to do it:
https://msdn.microsoft.com/en-us/library/cc668201(v=vs.100).aspx
hope it helps

how to show dynamic html page instead of aspx page with query string variables

we are using framework 3.5 please let me know how can I achieve following
instead of showing
http://www.mydomain.com/microsite/index.aspx?projid=3&adid=5
I want to show something like
http://www.mydomain.com/[cityname]/[keyword]/[customer-project-name]/index.html
where [cityname],[keyword],[customer-project-name] will be dynamic based on projid, adid
we want to do this for SEO
Use Urlrewritting to make your pages more Url / user friendly.
Please consider reading below mentioned articles and that may be helpful to you.
http://msdn.microsoft.com/en-us/library/cc668201.aspx
How to SEO friendly an existing ASP .NET 3.5 web application under IIS6
You could create a HttpModule which rewrite the url or use a existing Url Rewriting Module like UrlRewriter.net . Here is a blog post about this subject.

asp.net 4 url routing, how to access the route?

I'm using ASP.Net 4 URL routing on a web forms site.
I have multiple routes to a single page
routes.MapPageRoute("","our-services", "~/Information.aspx");
routes.MapPageRoute("","our-company", "~/Information.aspx");
On the destination page (Information.aspx) how can I tell which route was used to get there, for example was it from our-services or our-company?
You can try with
HttpRequest.RawUrl
it should contain the original URL that was called (i.e. before the rewriting)
From the information page, you could check who referred to it via Request.UrlReferrer.
HTH.

ASP.NET webpages without names, like stackoverflow?

Mentioned stackoverflow only as an example, but if you look above the URL for ask is
http://stackoverflow.com/questions/ask
which means /ask is a subdirectory, but they also do this for the specific question pages. How do you code this in .NET?
Not a code question as much as a technique. I know this is great for SEO, but how do you create a site so that every "page" is its own directory? Dynamically.
Do you have a template or a hidden redirect???
How?? :)
It's termed URL rewriting:
Url Rewriting with ASP.NET
MSDN: URL Rewriting in ASP.NET
EDIT: As #Justice points out, StackOverflow uses Routing.
StackOverflow uses something called Routing, which comes with .NET 3.5 SP1. Routing is a popular feature of a number of MVC frameworks, such as ASP.NET MVC, Ruby on Rails, and a number of Python and PHP frameworks.
Stack Overflow was built using ASP.NET MVC which uses a technique called Routing, see:
What Was Stack Overflow Built With?
and Routing
Stack Overflow uses ASP.net MVC
MVC uses the URL + Query String to determine the content, so its not like a URL which points to a specific page, but more like a hierarchical path to the properties of some data to be displayed
E.G. https://stackoverflow.com/users/[Put User ID Here]/[Put User Name Here]
prompts the website to display a USER with an ID specified in the path ( in this case the user name is probably just for kicks ) as opposed to a specific page created just for that user.
I have seen this accomplished by simply creating a folder for every web page and then having each folder contain a Default.aspx document (Assuming Default.aspx is setup as a default document in IIS, which it is by default). Then you can navigate to any folder on the site without specifying the page (Default.aspx).
For the dynamic part, I have worked with CMS systems that do it this way and the Default.aspx page simply inherits from some master template and the CMS system utilizes the ASP.NET rendering enginge to dynamically complete the web page.
Using folders may be a little heavy with the site structure, but it is an easy way to eliminate the page names from the browser.
This is how I structure my website and avoid having to use page names... for example http://www.innovaapps.net/Blog simply brings up the default.aspx page without having to specify the page name.

Resources