小编rud*_*dib的帖子

ASP.NET MVC URL生成性能

ASP.NET MVC的一个小基准.查看页面代码:

    public string Bechmark(Func<string> url)
    {
        var s = new Stopwatch();
        var n = 1000;

        s.Reset();
        s.Start();
        for (int i = 0; i < n; i++)
        {
            var u = url();
        }
        s.Stop();
        return s.ElapsedMilliseconds + " ms, " + ((s.ElapsedMilliseconds) / (float)n) + " ms per link<br/>";
    }
Run Code Online (Sandbox Code Playgroud)

查看代码:

<%= Bechmark(() => Url.Action("Login", "Account")) %>

<%= Bechmark(() => Url.Action("Login", "Account", new {username="bla", password="bla2", returnurl="blabla32", rememberme=false} )) %>

<%= Bechmark(() => Html.BuildUrlFromExpression<AccountController>(a=>a.ChangePassword("bla", "bla", "ya")) ) %>
Run Code Online (Sandbox Code Playgroud)

使用ASP.NET MVC Beta在默认新项目模板上的典型Core2笔记本上运行此命令会产生以下结果: …

c# performance asp.net-mvc-routing

15
推荐指数
1
解决办法
3657
查看次数

ASP.NET URL验证

我们在ASP.NET上有一个自定义REST处理程序,它配置如下,以处理所有传入的请求:

<add path="*" verb="*" type="REST.RESTProtocolHandler"/>
Run Code Online (Sandbox Code Playgroud)

但是,传递一个管道字符,正确编码或根本不编码,会触发一个似乎来自ASP.NET内部的验证错误.

访问http://localhost:8080/%7chttp://localhost:8080/|产生此错误:

[ArgumentException:path中的非法字符.] System.IO.Path.CheckInvalidPathChars(String path)+7489125 System.IO.Path.Combine(String path1,String path2)+40 System.Web.Configuration.UserMapPath.GetPhysicalPathForPath(String path) ,VirtualDirectoryMapping mapping)+114 System.Web.Configuration.UserMapPath.GetPathConfigFilename(String siteID,VirtualPath path,String&directory,String&baseName)+72 System.Web.Configuration.UserMapPath.MapPath(String siteID,VirtualPath path)+30 System. Web.Configuration.UserMapPath.MapPath(String siteID,String path)+31 System.Web.Hosting.HostingEnvironment.MapPathActual(VirtualPath virtualPath,Boolean permitNull)+297 System.Web.Hosting.HostingEnvironment.MapPathInternal(VirtualPath virtualPath,Boolean permitNull) +51 System.Web.CachedPathData.GetConfigPathData(String configPath)+341 System.Web.CachedPathData.GetVirtualPathData(VirtualPath virtualPath,Boolean permitPathsOutsideApp)+110 System.Web.HttpContext.GetFilePathData()+36 System.Web.HttpContext.GetConfigurationPathData()+26 System.Web.Configuration .RuntimeConfig.GetConfig(HttpContext context)+43 System.Web.Configuration.CustomErrorsSection.GetSettings(HttpContext context,Boolean canThrow)+41 System.Web.HttpResponse.ReportRuntimeError(Exception e,Boolean canThrow,Boolean localExecute)+101 System.Web .HttpRuntime.FinishRequest(HttpWorkerRequest wr,HttpContext context,Exception e)+383Web.HttpContext.GetConfigurationPathData()+ 26 System.Web.Configuration.RuntimeConfig.GetConfig(HttpContext context)+43 System.Web.Configuration.CustomErrorsSection.GetSettings(HttpContext context,Boolean canThrow)+41 System.Web.HttpResponse.ReportRuntimeError( Exception e,Boolean canThrow,Boolean localExecute)+101 System.Web.HttpRuntime.FinishRequest(HttpWorkerRequest wr,HttpContext context,Exception e)+383Web.HttpContext.GetConfigurationPathData()+ 26 System.Web.Configuration.RuntimeConfig.GetConfig(HttpContext context)+43 System.Web.Configuration.CustomErrorsSection.GetSettings(HttpContext context,Boolean …

asp.net iis url

10
推荐指数
1
解决办法
3149
查看次数

标签 统计

asp.net ×1

asp.net-mvc-routing ×1

c# ×1

iis ×1

performance ×1

url ×1