URL redirection in ASP.NET

Can someone suggest me which is the best method for rewriting urls for an ASP.NET 3.5 web application?

thank

+3
source share
6 answers

If you are using IIS 7 for your ASP.NET application, you can download:

If you are using IIS 6 or IIS 5, you may need to use the following open source component:

+3
source

Which web server?

If it is an Apache HTTP server, then mod_rewrite is probably the best choice.

, , , - -.


URL Rewriter And Reverse Proxy, mod_rewrite IIS 6 IIS 7 ASP.NET.

+2

ASP.NET 3.5 SP1, ASP.NET UrlRouting. Chris Cavanagh Phil Haack.

+1

, UrlRewritingNet.UrlRewrite, .

, ( ) URL.

, 404 , URLRewrite web.config, " " IIS. , .

http://forums.asp.net/p/890825/1017645.aspx

http://blog.codeville.net/2008/07/04/options-for-deploying-aspnet-mvc-to-iis-6/

+1

- script (.. index.php), URL script. , .

0

URL- / - .

The following is a stripped-down version of URL rewriting in IIS 6.

Here is a very simple version of URL rewriting that you can put in your Global.asax or Global.asax.cs file at the root of your site.

This piece of code. Redirects the URL / Store / Categories / to / Store / Default.aspx? Action = categories, while the user sees / Saves / Categories / in his URL, your application sees the URL as /Default.aspx? action = categories and Request ["action"]. ToString () will have a value of "categories"

void Application_BeginRequest(object sender, EventArgs e)
{
    string fullOriginalpath = Request.Url.ToString().ToLower();

    if (fullOriginalpath.Contains("/store/categories/"))
    {           
        Context.RewritePath("/Store/Default.aspx?action=categories");           
    }
    else if (fullOriginalpath.Contains("/store/products/"))
    {
        Context.RewritePath("/Store/Default.aspx?action=products");
    }
}
0
source

Source: https://habr.com/ru/post/1726795/


All Articles