The ASP. Net extension does not display and get the URL value

Source: Internet
Author: User

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

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.