URL parameters in ASP. net mvc Request

Source: Internet
Author: User

In ASP. net mvc, the return value of URL-related attributes in the Request object.

Request. OriginalString // return the original address, that is, the native content in the browser http: // localhost: 3638/Test/Show? Id = 1 Request. RawUrl // return a string that does not contain the Host Address information/Test/Show? Id = 1 Request. Query // parameters in the returned path. parameters are usually included in the/method in ASP. net mvc, but what is returned here? The value behind it, so the/mode parameter cannot be seen here? Id = 1 Request. Schema // return Request Type http Request. Port // return Port value 3638 Request. LocalPath // return? But does not include the Host information/Test/Show Request. PathAndQuery // returns the same content as RawUrl/Test/Show? Id = 1 Request. segments // returns a string array, which divides LocalPath into a string array ["/", "Test/", "Show"] Request. originalString // return the original address, that is, the native content in the browser http: // localhost: 3638/Test/Show? Id = 1Request. RawUrl // return a string that does not contain the Host Address information/Test/Show? Id = 1Request. Query // parameters in the returned path. parameters are usually included in the/method in ASP. net mvc, but what is returned here? The value behind it, so the/mode parameter cannot be seen here? Id = 1Request. Schema // return request type httpRequest. Port // return Port value 3638Request. LocalPath // return? But does not include the Host information/Test/ShowRequest. PathAndQuery // returns the same content as RawUrl/Test/Show? Id = 1Request. Segments // return a string array. Divide LocalPath into a/String Array ["/", "Test/", "Show"]

In a Controler or ActionFilter, if you want to obtain the name of the current Controller, Request. Segments [1]. If you want to obtain the name of the current Action, Request. Segments [2]

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.