Plus (+) in MVC Argument causes 404 on IIS 7.0

前端 未结 4 698
面向向阳花
面向向阳花 2020-12-14 06:54

I have an MVC route that is giving me hell on a staging server running IIS. I am running Visual Studio 2010\'s development server locally.

Here is a sample URL that

4条回答
  •  无人及你
    2020-12-14 07:34

    Totally agree with @bobince, the problem is in the wrong encoding to %2b instead of %20

    Sadly HttpUtility.UrlEncode is misleadingly-named. It produces + in its output instead of %20, so it's really a form-URL-encoder and not a standard URL-encoder. Unfortunately I don't know of an ASP.NET function to “really URL-encode” strings for use in a path, so all I can recommend is doing a string replace of + to %20 after encoding.

    this is the important part, which is to replace the + sign with %20

提交回复
热议问题