The following mappings are often used in projects
Will
Http://onewww.net/a.aspx?name=llinzzi
Mapped to
Http://onewww.net/llinzzi
There are 2 problems to solve first
The first is to support wildcard mapping URL mapping is asp.net2.0 new features, do not support wildcards
Then the Nbear NBear.Web.Modules.UrlRewriteRules is used to map wildcard characters.
<?xml version= "1.0"?>
<!--
Note: In addition to manually editing this file, you can also use the
WEB Administration Tool to configure settings for your application. Can be used in Visual Studio
The Web site-> the asp.net configuration option.
The complete list of settings and comments is
Machine.config.comments, this file is typically located in the
In \Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration xmlns= "http://schemas.microsoft.com/.NetConfiguration/v2.0" >
<configSections>
<section name= "Urlrewriterules" type= "NBear.Web.Modules.UrlRewriteRules, Nbear.web"/>
</configSections>
<UrlRewriteRules>
<rule key= "/(. *)/" value= "/a.aspx?name=$1"/>
<rule key= "/(. *)" value= "/a.aspx?name=$1"/>
</UrlRewriteRules>
<!--
Set compilation debug= "True" to insert debug symbols
Pages that have been compiled. But since this will
Affect performance, so this value is only in the development process
Set to True.
-->
<compilation debug= "true" defaultlanguage= "C #"/>
<!--
The <authentication> section allows you to configure the asp.net used by
Secure authentication Mode,
To identify the incoming user.
-->
<authentication mode= "Windows"/>
<!--
If an unhandled error occurs during the execution of the request,
The <customErrors> section allows you to configure the appropriate processing steps. Specifically
The section enables developers to configure
HTML error page to display
In place of the error stack trace.
Checked a few times, did not find the problem, think carefully
First, the workflow for IIS should be to encounter an. aspx extension and give it to. NET processing before calling httpmodules for URL mapping
Http://onewww.net/llinzzi
No aspx extension, so IIS is directly a file rack, returning 404 errors
The debug Web server in vs2005, however, succeeded by sending all requests to. NET processing.
So change the image
<rule key= "/(. *)/index.aspx" value= "/a.aspx?name=$1"/>
Browse
Http://onewww.net/llinzzi/index.aspx
The test was successful.
Happy, set the index.aspx as the default document
Test http://onewww.net/llinzzi/result or 404 error
Think about it. IIS believes that the Llinzzi folder does not exist and naturally does not use the default document to access
Depressed, thinking a lot of ways, all failed
Do you want to use llinzzi/index.html access? Do you want to generate a folder that really exists?
are not the ideal solution.
While attempting to modify the ISAPI from the configuration in the home directory in IIS to implement the parsing of the folder against IIS, I suddenly discovered that the IIS6 on the WINDOWS2003 server compared to the IIS5 on my work machine XP, called
Wildcard application mapping settings, eye light. The first name sounds like a door, and the No. 22003 is built for. Net. So dot Insert,
Input C:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll
Test, Success!
Searched for the following information about wildcard application mappings
Install wildcard Application Mappings
In IIS 6.0, an administrator can configure a Web site or virtual directory to run an Internet server API (ISAPI) whenever a request is sent to a Web site or virtual directory, regardless of the file name extension requested.
When an IIS Web server receives a request from a client, the Web server looks at the file name extension that is named in the request to determine which ISAPI or public gateway Interface (CGI) application is to process the file. For example, if you request a Web page named Default.asp, IIS can know from the list of application mappings that Default.asp is handled by the Asp.dll ISAPI application.
If you want to perform a specific task on each client request before the requested page is sent to the mapped application, you can write an ISAPI filter to intercept the request when it arrives. However, the ISAPI filter has the following limitations:
They do not have access to the request body, but only to the headers.
They can only be configured at each site, not in each virtual directory.
They should not contain long-running operations, because ISAPI filters are synchronized.
They are less flexible because the ISAPI filter API has less functionality than the ISAPI extension API, which is used to write ISAPI applications.
They are difficult to manage in time.
They are event-driven.
By using the wildcard application mappings, you can intercept each request before the requested page is sent to its mapped application. The effect is like having an application map that handles each file name extension. This is why you use the wildcard character to name this feature. Applications that use wildcard application mappings can only be ISAPI applications.
Client requests take the following route:
Incoming requests are processed by any existing ISAPI filters that are installed on the root web. The ISAPI filter executes sequentially.
Requests are sent to any existing wildcard application-mapped applications, and these programs are executed sequentially. If the incoming request is for a Web file in the virtual directory, and the wildcard application mapping is already installed on the virtual directory and the root Web, only the wildcard application mappings installed in the virtual directory are executed. If no wildcard application mappings are installed on the virtual directory, the wildcard application mappings that are installed on the Web site are executed. In other words, the wildcard application mappings are inherited only if there is no mapping in the application where the requested Web file is in.
The IIS server looks at the application mapping table to determine which ISAPI application or CGI script specifically handles the requested file.
Each stage can attach a response and then pass it back to the client.
Using wildcard Application Mappings
Wildcard application mappings can be used in the following scenarios:
High-security WEB applications, such as banking applications, require that each requesting user be authenticated based on the user name, password, and account number database. For example, once a user has passed authentication, a specific rule is created that will specify what information the user can access. If the wildcard application mapping determines that the user does not have the appropriate rights, it can block further access to the request, or send the request to a Web page other than the requested page. This custom authentication and authorization scheme can be executed in an ISAPI application and installed as a wildcard application mapping. In this way, all users must authenticate, regardless of the file name extension that they requested.
Ad-commerce sites for individual users. For example, when a user's request is returned, the wildcard application mapping application checks their identities and then queries the items they have previously viewed or purchased. Once the wildcard script map transfers control to the requested page, it can display ads that are appropriate for that user.
Important You must be a member of the Administrators group on the local computer or you must be delegated the appropriate permissions to perform the following steps. As a security best practice, log on to the computer using an account that is not part of the Administrators group, and then run IIS Manager as an administrator using the Run as command. At the command prompt, type runas/user:administrative_accountname mmc%systemroot%\system32\inetsrv\iis.msc.
To add a wildcard application mapping to a Web server or Web site
In IIS Manager, expand the local computer, expand the Web Sites folder, right-click the Web site or virtual directory that you want, and then click Properties.
Click the appropriate tab: Home directory, virtual directory, or directory.
In the Application Settings area, click Configure, and then click the Mappings tab.
To install the wildcard application mappings, do the following:
On the Mappings tab, click Insert.
Type the path to the DLL in the executable text box or click Browse to locate the file, if the DLL file is a script engine, select the Application engine check box, and then click OK.
To edit or delete a wildcard application mapping, do the following:
In the Application Extensions list, click the script map that you want to change.
Click Edit to change the script map, or click Delete to delete the script map.
To change the order in which the wildcard application is executed, rearrange the wildcard application mappings in the wildcard Application mappings (execution Order) box by clicking the Move up or Move Down button until the order you want is met.
Note Do not list the same application multiple times in the wildcard Application Mappings list.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.