First of all, download URLRewriter, download and install ghost, and find the URLRewriter. dll file in the bin directory.
Then, reference the file to the project and configure the file as follows:
1. Add the following code to the web. config file:
<Configuration>
<ConfigSections>
<Section name = "RewriterConfig" type = "URLRewriter. Config. RewriterConfigSerializerSectionHandler, URLRewriter"/>
</ConfigSections>
</Configuration>
Where
<Section name = "RewriterConfig"
Type = "URLRewriter. Config. RewriterConfigSerializerSectionHandler, URLRewriter"/>
</ConfigSections>
The handler class used to specify the configuration section "RewriterConfig" is named "URLRewriter. Config. RewriterConfigSerializerSectionHandler", which exists in the URLRewriter. dll file in the bin directory.
2. Add the following code to the system. web node in the web. config file:
<HttpHandlers>
<Add verb = "*" path = "*. html"
Type = "URLRewriter. RewriterFactoryHandler, URLRewriter"/>
</HttpHandlers>
This Code indicates that the file extension is.html All HTTP requests of the file are mapped to the class.URLRewriter. for details about RewriterFactoryHandler, refer to MSDN. Here I made a mistake. path = "*. html "is written as path =" *. aspx "causes a page not found and a 404 error occurs.
3. Rewrite the url
Like 1 <Configuration> </Configuration> below the node
The key is
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor> ~ /Shownews/news (\ d +) \. html </LookFor>
<SendTo> ~ /Shownews. aspx? ShowID = $1 </SendTo>
</RewriterRule>
<RewriterRule>
<LookFor> ~ /Product (\ d +) \. html </LookFor>
<SendTo> ~ /Showproduct. aspx? ShowID = $1 </SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
The key lies in the transformation of uml.
<LookFor> ~ /Shownews/news (\ d +) \. html </LookFor>
<SendTo> ~ /Shownews. aspx? ShowID = $1 </SendTo>
It means converting the first path into another path. The Regular Expression in <LookFor> () is the parameter $1 in the second sentence.
You can also use $2 $3 to represent the parameters in the second third () of <LookFor>.
It's okay now, huh, huh. I am so excited. Don't worry, it's just the simplest. If your page has a return request. For example, if you put the DATAGRID on the page and there are pages, you will find that the page goes down to the next page, and then you will find a problem again.
What should I do now? In fact, I have mentioned it on Microsoft's website. I will briefly describe it here.
Step 6: add the component for form return Persistence:
Find ActionlessForm. dll in the project you downloaded and put it in the bin directory of your project.
Then add the following to your page:
<% @ Register TagPrefix = "skm" Namespace = "ActionlessForm" Assembly = "ActionlessForm" %>
Change <Form...>:
<Skm: Form id = "Your Form name" method = "post" runat = "server">
.....
</Skm: Form>
That's All. Now you can rest assured