当我使用WebRequest.Create(" http:// abc/test.")进行GET时,我得到404,因为根据fiddler,尾随点被.NET剥离,Web服务器需要点.我该如何防止或解决它.任何解决方法表示赞赏!
采取以下控制器操作
public ActionResult NextBySURNAME(int id, string data)
{
//code to process the data and edit the id accoringly not written yet
return RedirectToAction("Edit", new { id = id });
}
Run Code Online (Sandbox Code Playgroud)
如果我用/ Mycontroller/NextBySURNAME/12/Smith%20Simon调用它
然后它工作正常(在这种情况下编辑记录12)但是
/ myController的/ NextBySURNAME/12 /史密斯%20
给了我一个404
现在我知道在某些情况下我的问题域尾随空白是很重要的,所以我不只是想修剪它.那为什么这会破坏我的路线呢?
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}/{data}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional, data=UrlParameter.Optional } // Parameter defaults
);
Run Code Online (Sandbox Code Playgroud)