开发者

How does the URL Rewrite Module Work

开发者 https://www.devze.com 2023-01-16 19:21 出处:网络
I\'m probably going to use the URL rewrite mo开发者_StackOverflow社区dule for IIS 7 eventually and I have a fairly straight forward question that I really can\'t find the answer to.

I'm probably going to use the URL rewrite mo开发者_StackOverflow社区dule for IIS 7 eventually and I have a fairly straight forward question that I really can't find the answer to.

If you have a base case of:

http://yoururl.com/page.aspx?ID=7

You can obviously have it rewritten to:

http://yoururl.com/page/7 or whatever you want.

My question is this: When using this module can you still use Request.Querystring["page"] on the rewritten querystring. How does the Request.URL stuff work. Does asp.net still provide the un-rewritten url or does it provide the rewritten one.

I would assume that your C#/asp.net code is completely unaffected by the url rewriting, as that's more or less the point, but I want to be crystal clear.

Secondary question: What is the best practice for how you should code a website when using the rewritten. Should you code links in the written style, or continue using querystrings?


  • When using this module can you still use Request.Querystring["page"] on the rewritten querystring.

Yes, you will be able to access the re-written QueryString in that way.

  • How does the Request.URL stuff work. Does asp.net still provide the un-rewritten url or does it provide the rewritten one.

Request.Url will be the re-written URL, but Request.RawUrl will be the original URL.

  • Should you code links in the written style, or continue using querystrings?

Yes, code your links in the way you want them to be seen by end users, and then in your code ensure you're aware of and document the changed format.

There is loads of information and tutorials on the IIS website here:

http://learn.iis.net/page.aspx/460/using-the-url-rewrite-module/

0

精彩评论

暂无评论...
验证码 换一张
取 消