ASP. NET 2.0 URL ing skills.

Source: Internet
Author: User
The following mappings are often performed in projects:
Set

Http://onewww.net/a.aspx? Name = llinzzi

Map

Http://onewww.net/llinzzi

First, we need to solve two problems.
The first is to support wildcard URL ing URL ing, which is a new feature of ASP. net2.0 and does not support wildcard
Therefore, nbear. Web. modules. urlrewriterules is used for wildcard ing.

<? XML version = "1.0"?>
<! --
Note: In addition to manually editing this file, you can also use
Web management tools to configure application settings. You can use
"Website"-> "ASP. NET configuration" option.
The complete list of settings and comments is displayed in
In machine. config. Comments, this file is usually located 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>

<Appsettings/>

 

<System. Web>

<Sessionstate timeout = "200"/>
<Httpmodules>
<Add type = "nbear. Web. modules. urlrewritemodule, nbear. Web" name = "urlrewritemodule"/>
</Httpmodules>

<! --
Set compilation DEBUG = "true" to insert the debugging symbol
Compiled pages. However, this
Performance is affected, so this value is only available during development.
Set to true.
-->
<Compilation DEBUG = "true" defaultlanguage = "C #"/>
<! --
In the <authentication> section, you can configure
Security Authentication mode,
To identify the user.
-->
<Authentication mode = "Windows"/>
<! --
If an unprocessed error occurs during request execution,
You can configure the corresponding processing steps in the <mermerrors> section. Specifically,
This section allows developers to configure
HTML error page to be displayed
To replace the error stack trace.

<Customerrors mode = "remoteonly" defaultredirect = "genericerrorpage.htm">
<Error statuscode = "403" Redirect = "noaccess.htm"/>
<Error statuscode = "404" Redirect = "filenotfound.htm"/>
</Customerrors>
-->
</System. Web>
</Configuration>

The test is successful in vs2005, but it fails to be put in IIS.

I checked several times and did not find any problems. I thought about it carefully.

First, the IIS workflow should meet the. aspx extension and be handed over to. Net for processing before you can call httpmodules for URL ing.

Http://onewww.net/llinzzi

No aspx extension, so IIS is used as a file shelf and Error 404 is returned.
The debug web server in vs2005 sent all requests to. Net for processing, so the request was successful.
Therefore, it is changed
<Rule key = "/(. *)/index. aspx" value = "/a. aspx? Name = $1 "/>
Browse

Http://onewww.net/llinzzi/index.aspx

The test is successful.
Happy! Set index. aspx to the default document
Test http://onewww.net/llinzzi/ result or 404 error
I thought about IIS and thought that the llinzzi Folder does not exist. Naturally, it is useless to access the default document.

Depressed, failed after thinking a lot of methods
Should I use llinzzi/index.html for access? Do you want to generate a folder that actually exists?
None of them are ideal solutions

When you try to modify the ISAPI from the configuration in the main directory of IIS to parse IIS using folders, I suddenly found that IIS6 on Windows Server is named more than iis5 on Windows XP Server.
The setting of wildcard application ing is eye-catching. The first word sounds good, and the second 2003 is originally created for. net. So click Insert,
Enter c: \ windows \ microsoft.net \ framework \ v2.0.50727 \ aspnet_isapi.dll
Test, successful!

Searched for information about the wildcard application ing.

Install wildcard application ing
In IIS 6.0, the administrator can configure the website or virtual directory to run the Internet Server API (ISAPI) each time a request is sent to a website or virtual directory ), regardless of the file extension.

When the IIS web server receives a request from a client, the web server will view the file extension named in the request to determine which ISAPI or public Gateway Interface (CGI) exists) application to process the file. For example, if you request a webpage named default. asp, IIS can know from the application ing list that default. asp is processed by the ASP. dll ISAPI application.

If you want to execute a specific task for 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 restrictions:

They cannot access the Request body, but only the access header.
They can only be configured on each site, but not on 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 fewer functions than the ISAPI extension API, which is used to compile ISAPI applications.
They are difficult to manage in time.
They are event-driven.

By using wildcard application ing, You can intercept each request before the requested page is sent to its ing application. The effect is like an application ing that processes each file name extension. This is why "wildcard" is used to name this function. Only ISAPI applications can be mapped with wildcard applications.

Client requests use the following routes:

The incoming request is processed by any existing ISAPI filter installed on the Root website. ISAPI filters are executed in sequence.
Requests are sent to any existing wildcard application mapped applications, which are also executed in sequence. If the incoming request is for web files in the virtual directory, and the wildcard application ing has been installed on the virtual directory and the root website, then, only the wildcard application ing installed in the virtual directory is executed. If no wildcard application ing is installed on the virtual directory, the wildcard application ing installed on the website is executed. In other words, the wildcard application ing is inherited only when the requested Web file is not mapped in the application.
The IIS server will view the application ing table to determine which ISAPI application or CGI script specifically processes the requested file.
Each stage can append a response and send it back to the client.
Use wildcard application ing
Wildcard application ing can be used in the following scenarios:

High-security web applications (such as banking applications) require identity verification based on the user name, password, and account number database of each requesting user. For example, once a user passes authentication, a specific rule is created that specifies the information that the user can access. If the wildcard application ing determines that the user does not have the corresponding rights, it can block further access to the request, or send the request to a webpage other than the requested webpage. This custom authentication and authorization scheme can be executed in the ISAPI application and installed as a wildcard application ing. In this way, all users must pass authentication, regardless of the file extension they requested.
An advertisement e-commerce website targeting a single user. For example, when a user's request is returned, the wildcard application ing application checks their identity and then queries the items they previously viewed or purchased. Once the wildcard script ing is transferred to the requested page, the ads that are suitable for this user can be displayed.
Important you must be a member of the Administrators group on the local computer or be granted permissions to perform the following steps. As the best security operation, log on to your computer using an account that is not in the Administrators group, and run the command as an administrator to run IIS manager. At the command prompt, type RunAs/User: administrative_accountname "MMC % SystemRoot % \ system32 \ inetsrv \ IIS. msc ".

Add a wildcard application ing to a Web server or website

In IIS manager, expand the Local Computer, expand the "website" folder, right-click the desired website or virtual directory, and click "properties ".
Click the corresponding tab: "main directory", "virtual directory", or "directory ".
In the application settings area, click configuration, and then click the ing tab.
To install the wildcard application ing, perform the following operations:
On the ing tab, click Insert ".
In the executable file text box, type the dll path or Click Browse to find the file. If the DLL file is a script engine, select the application engine check box, click OK ".
To edit or delete the wildcard application ing, perform the following operations:
In the Application Extensions list, click the script ing you want to change.
Click Edit to change the script ing, or click Delete to delete the script ing.
To change the execution sequence of a wildcard application, reschedule the wildcard application ing in the "wildcard application ing (execution sequence)" box, you can click the "Move Up" or "Move Down" button until it meets the order you want.
Note: do not list the same application multiple times in the wildcard application ing list.

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.