In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how ASP.NET implements url rewriting. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
If you are looking for this article, you should all know what a second-level domain name is. Let's not talk nonsense. But before we discuss it, we must first understand a question of thought. The question that many of my friends have been wondering (and I didn't understand the other day) is, after I typed an address, how could it be rewritten by ASP.NET url?
* step: what happens after typing an address in the browser, such as http://love.kerry.com, and clicking enter? To simplify the problem, let me explain it this way.
Step 2: first, the address you typed is parsed and ends up on a web server. Leave it to IIS. In the ASP.NET world, IIS passes such a request to a web processor, * *, which returns the result to the browser and displays it to the user.
Please don't ignore the problem that everything in the second step is done on the server side. While these things are going on, the address on the client's browser will not change. Even if the web processor returns the processing result, the address above will not change. The url typed at the beginning just acts as a knock on the door. When the door is knocked, even if the effect is over, only your eyes can see the address, the browser, the server and so on do not know this address. Then the problem to understand is that the so-called ASP.NET url rewriting is only the inside story that web developers know. The user has no idea what happened, and he thinks the address he typed is the result that should be displayed on the screen. In other words, we control what is displayed behind the scenes. The next thing to consider is, how do you control what is displayed?
From the process mentioned above, it is obvious that we have to tamper with the work of the web processor.
One of the simplest considerations is that the user types in a simple address without any parameters, http://love.kerry.com, and then we change the address to an address with parameters that meets the needs of the program, which is processed by http://kerry.com?lover=notus.
The so-called ASP.NET url rewriting is at this step. In .net terms, we need to register a httpmodule for the application to handle the specific url registration httpmodule, web.config, and url, which is roughly equivalent to this in the httpmodule program we provide.
/ / use our httpmodule program to intercept the original url String OriginalUrl= "http://love.kerry.com"; / / process the original url and get the * required url with a value of http://kerry.com?lover=notus String FinalUrl=Rewrite (OriginalUrl); / / context re-sends the url internally to the IIS processing context.RewritePath (FinalUrl)
Next, let's implement ASP.NET url rewriting.
* * step: determine which url to rewrite, that is, make rewriting rules
Step 2: write httpmodule handlers
Step 3: integrate the written httpmodule into the web program and get started.
The above is the basic knowledge of ASP.NET url rewriting, and the process of using ASP.NET url rewriting to achieve a secondary domain name is the same. Because whether it is a second-level domain name or a third-level domain name, it is an url address. As long as we intercept this url address, we can tamper with it.
Some problems will be encountered in the process of implementation, mostly due to careless reading of the above articles, but to tell you the truth, it is not easy to finish such a long article. Let me record some important questions. The two problems of * show how to deal with the rewritten target url to meet our requirements with specific code.
Why do we have to use universal parsing?
After reading a lot of friends' responses, I think there may be such a misunderstanding now, that is, this article on ASP.NET url rewriting is just to introduce some ways to deal with it. As for pan-parsing and not pan-parsing, it is not important.
If you do not need to implement any second-level domain name, then there is no need to achieve universal resolution, just fix the second-level domain name you need and deal with it in ASP.NET url rewriting! To take a step back, if you don't even need to implement a second-level domain name and just rewrite the url under a fixed domain name, you don't need to modify the urlrewriter of msdn. You can simply rewrite ASP.NET url with it. Zyw made changes to the project just to get more control over all the url. And as we can see, at first, the urlrewriter of msdn didn't care about the domain name.
Thank you for reading! This is the end of the article on "how to achieve url rewriting in ASP.NET". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.