hide page extension in url - asp.net

How can i hide page extension (for ex .aspx , .php) from url of the page

I think you should use IIS URL Rewriter module.
http://learn.iis.net/page.aspx/460/using-the-url-rewrite-module/

Here you have a good article about how to achive friendly urls on asp net
http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx
It covers 4 options
Use Request.PathInfo Parameters Instead of QueryStrings
Using an HttpModule to Perform URL Rewriting
Using an HttpModule to Perform Extension-Less URL Rewriting with IIS7
ISAPIRewrite to enable Extension-less URL Rewriting for IIS5 and IIS6

If you have IIS6 server, you have to do few modification in order to ASP.NET ISAPI catch extension-less url. In IIS7, use Integrated pipeline application pool. Then with some URL rewriter or mapper (ASP.NET Routing, UrlRewriting.NET,...) configure your urls to physical files or MVC controller/action.

Related

Extensionless URL in ASP.NET 4.0 on IIS6

I have a ASP.NET 4.0 WebForms webapp running on a IIS6 webserver. I'm not allowed to make any changes to the webserver. I have a flex app embedded in this file called:
myapp.contoso.com/mysubapp/mysubapp.aspx
I'd like to only require the user to use the URL:
myapp.constoso.com/mysubapp
to reach the application and essentially hid the mysubapp.aspx permanently. I've been checking out URLRewrite and URLRewriting.net... It all looks to be a little much for this once instance in which I need it (if I need to add more rewrites in the future I'll use one of those frameworks). Is there a simple way to achieve this? I've checked out similar posts... it seems that I may need to write a simple one myself?
URL Rewriting using iis6 with no extensionless urls
How to deal with extensionless Url in ASP.Net and IIS6
The simplest thing I can think of is to rename your web page from mysubapp.aspx to default.aspx. This will allow users to request myapp.constoso.com/mysubapp and get your page. This should work if you have not removed default.aspx from the default document list in IIS.
Alternatively, you can add mysubapp.aspx to the list of default documents in IIS.

Remove aspx extension from SharePoint pages

I would like to remove the ".aspx" extension from pages in a SharePoint web application. This can be done with URL rewriting in IIS web applications, but I cannot find any way to achieve this is SharePoint site pages.
e.g. abcsite/pages/default.aspx should be abcsite/pages/default.
I don't know much about Sharepoint but you can use Url Routing with ASP.NET as an alternative to IIS Rewrite Modules.
One advantage being that forms post back to the correct URL which I prefer (without having to reverse map using IIS Url Rewriting)
Note: Available from .NET 4.0
I am not sure which version of sherepoint you are using.
You can use IIS URL Rewrite 2.0 module
Please have a look at these example which has setp by step instructions
IIS7 URL Rewrite module
SharePoint 2010 with IIS URL Rewrite 2.0
URL Routing with ASP.NET 4.0

Rewriting url in IIS7

i have setup a website and using IIS7, now what i want to do is when user hits the domain, it should take the user to another page, for example say user hits m.abc.com, url should be rewrited to m.abc.com/section/news, however /section/news should not be displayed in the addressbar, but the page should be news, in short i want url rewrite directly on root
There are basically two ways for doing url rewriting:
Using IIS add-in: http://www.iis.net/download/urlrewrite
Using asp.net url wriritng with http handlers: http://msdn.microsoft.com/en-us/library/ms972974.aspx
IIS has an add-in that you can install just for this purpose
http://www.iis.net/download/urlrewrite

How does ASP.NET WebPages implement extensionless URLs?

I'd like to implement the same thing for my own build providers.
I'm talking about an ASP.NET Webpages application, in Visual Studio: File > New Website > ASP.NET Website (Razor)
Works with Cassini, so it's not an IIS Express thing.
I found it, it's an HTTP module, System.Web.WebPages.WebPageHttpModule
This module checks if the file exists, and if it does it creates a handler from that file and remaps the request to that handler.
Razor is a templating engine. It has nothing to do with URLs. They are handled by the ASP.NET routing engine. Extensionless URLs are supported starting from IIS 7.0. In IIS 6.0 you need to associate the aspnet_isapi extension with all incoming requests if you want to support extensionless urls.
I found this information in regard to the "Routing" that you might find handy if you are building an ASP.Net WebPages site w/o MVC3 and wanted to mention it.
Creating More Readable and Searchable URLs - About Routing
HTH

How to rewrite a path using a custom HttpHandler

I'm writing a multi-tenant app that will receive requests like http://www.tenant1.com/content/images/logo.gif and http://www.anothertenant.com/content/images/logo.gif. I want the requests to actually map to the folder location /content/tenant1/images/logo.gif and /content/anothertenant/images/logo.gif
I'm using asp.net Mvc 2 so I'm sure there's probably a way to setup a route to handle this or a custom route handler? Any suggestions?
Thanks!
I created a custom HttpModule that taps into the BeginRequest event and then checks to see what the path is then calles Context.RewritePath
If I understand correctly, because it's URL rerouting, I don't know that MVC 2 routing handles this. You need IIS routing, which varies depending on the version you have. For IIS 6, there is an IIS resource toolkit that can handle these kinds of request, or there is helicontech.com's ISAPI_REWRITE or Ionic's rewriter at iirf.codeplex.com. IIS 7 has an MS add-on for url routing too, from what I hear, as a separate download.
These tools can actually redirect the URL in the ways you want, as MVC doesn't deal with the URL itself for the web site, but the pages within the URL request. the ISAPI_REWRITE and other tools actually redirect requests to hosts as you mentioned.

Resources