Get a complete url like http://google.com as action input

后端 未结 2 539
刺人心
刺人心 2021-01-21 07:19

I want to get url in my action to return the page\'s PageRank. I have a route like this:

routes.MapRoute(
    name: \"PRURL\",
    url: \"Utility/PR/{*url}\",
           


        
相关标签:
2条回答
  • 2021-01-21 08:08

    Try to add a requestPathInvalidCharacters attribute to httpRuntime

    <httpRuntime requestValidationMode="2.0" 
        requestPathInvalidCharacters="&lt;,&gt;,*,%,&amp;,\,?" />
    

    The default value is &lt;,&gt;,*,%,&amp;,:,\,?

    0 讨论(0)
  • 2021-01-21 08:17

    You can disable automatic request verification.

    In web.config:

    <pages validateRequest="false">
    

    Or for action:

    [ValidateInput(false)]
    public ActionResult PR(...
    

    And I forget about web.config. You need to add to web.config:

    <system.web>
      <httpRuntime requestValidationMode="2.0" />
    </system.web>
    

    Or you can encode/decode url

    0 讨论(0)
提交回复
热议问题