Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.net URL Rewriting

I would like to use the ASP.Net URL Rewriting to achieve the following:

My application is physically hosted in the IIS at the following end point: http://www.example.com/someIISApplication/Default.aspx

I want the user to make a request with the following URL and hit the above end point with a querystring parameter like this:

Requested from browser: http://www.example.com/ABC/someIISApplication/Default.aspx

This is how it actually hits the ASP.Net after route processing: http://www.example.com/someIISApplication/Default.aspx?MyParam=ABC

like image 506
Liquid Avatar asked Nov 19 '15 15:11

Liquid


People also ask

What is URL rewriting in asp net?

The concept of URL rewriting is simple. When a client sends a request to the Web server for a particular URL, the URL rewriting module analyzes the requested URL and changes it to a different URL on the same server.

What is URL rewriting in ASP NET MVC?

URL rewriting is the process of intercepting an incoming Web request and redirecting the request to a different resource. When performing URL rewriting, typically the URL being requested is checked and, based on its value, the request is redirected to a different URL.


1 Answers

You can use URL Rewrite Module for IIS .

Create redirect rule on the site level (www.example.com)

Pattern: ^([_0-9a-z-]+)/someIISApplication/Default.aspx

Redirect URL: someIISApplication/Default.aspx?MyParam={R:1}

For more details see "Creating Rewrite Rules for the URL Rewrite Module"

like image 99
Albert Avatar answered Sep 28 '22 04:09

Albert