Web site that is created by vs2013 to create a new Web Forms application, and the URL does not display an extension. That's the function today.
1, first open vs2013> new Project > such as Select
2. Select Project Right-click > Manage NuGet Package > enter in Search box (friendlyurls), search to post-point installation (after accepting the protocol, installation is complete):
3, pay attention to read Readme.txt, in the solution
4, open Routeconfig (routing configuration) and MVC in the same route, the original code modified,
After modification:
5. Select Project Right-click > Add > New Item > Global Application Class (Global.asax) settings as follows:
Adding the following code is when the program executes the method at startup (referring to its own reference)
protected void Application_Start (object sender, EventArgs e) { routeconfig.registerroutes (routetable.routes ); } protected void Application_Error (object sender, EventArgs e) { } protected void Application_End (object sender, EventArgs e) { }
View Code
6, create a new test Web Form (test.aspx) can write nothing, the effect is as follows:
7. Get the URL value:
Attention! Reference namespaces:
<%@ Import namespace="Microsoft.AspNet.FriendlyUrls" %>
<%@ Page Language="C #"AutoEventWireup="true"codebehind="Test.aspx.cs"Inherits="urltest.test" %><%@ Import NameSpace="Microsoft.AspNet.FriendlyUrls" %><!DOCTYPE HTML><HTMLxmlns= "http://www.w3.org/1999/xhtml"><Headrunat= "Server"><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"/> <title></title></Head><Body> <formID= "Form1"runat= "Server">Test Window<%foreach (var segment in request.getfriendlyurlsegments ()) {%> <P><%: Segment%></P> <% } %> </form></Body></HTML>
View Code
These can be done in the background with the following effects:
The ASP. Net extension does not display and get the URL value