惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
雷峰网
雷峰网
J
Java Code Geeks
G
Google Developers Blog
博客园 - 司徒正美
The GitHub Blog
The GitHub Blog
L
LangChain Blog
人人都是产品经理
人人都是产品经理
GbyAI
GbyAI
Vercel News
Vercel News
S
SegmentFault 最新的问题
Engineering at Meta
Engineering at Meta
H
Hackread – Cybersecurity News, Data Breaches, AI and More
云风的 BLOG
云风的 BLOG
F
Fortinet All Blogs
Y
Y Combinator Blog
博客园_首页
Last Week in AI
Last Week in AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
罗磊的独立博客
A
About on SuperTechFans
B
Blog
Microsoft Security Blog
Microsoft Security Blog

博客园 - 天际翔龙

一个苹果证书如何多次使用——导出p12文件[多台电脑使用] Log4net系列一:Log4net搭建之文本格式输出【转】 SMMS 2016 啟用深色主題 ZenCoding[Emmet]語法簡介【轉】 vscode: Visual Studio Code 常用快捷键【轉】 C#枚举Enum[轉] Android 杂记 解决genymotion-arm-translation.zip无法拖拽安装的问题[转] c#同步調用異步(async)方法【記錄用】 DDD基本概念 server2012/win8 卸载.net framework 4.5后 无法进入系统桌面故障解决【转】 Entity Framework中AutoDetectChangesEnabled為false時更新DB方法 git常用命令备忘录 MSSQL日誌傳輸熱備份注意事項 c#生成唯一编号方法记录,可用数据库主键 唯一+有序 Angular 隨記 使用dumpbin命令查看dll导出函数及重定向输出到文件【轉】 UML类图与类的关系详解【转】 知識隨記
c#代碼小集
天际翔龙 · 2018-03-26 · via 博客园 - 天际翔龙

一、字符串[Uri]轉換出RouteData

private RouteData UriToRouteData(Uri uri)
{
    var query = uri.Query;
    if (uri.Query.Length > 0)
    {
        query = query.Substring(1, uri.Query.Length - 1);
    }
    var request = new HttpRequest("", uri.AbsoluteUri, query);
    var routeData= Url.RouteCollection.GetRouteData(new HttpContextWrapper(new HttpContext(
        request,
        new HttpResponse(null))));

    if (request.QueryString.Count > 0 && routeData != null)
    {
        foreach (string key in request.QueryString.Keys)
        {
            routeData.Values.Add(key, request.QueryString[key]);
        }
    }

    return routeData;
}

//調用
//RouteData routeData = UriToRouteData(Request.UrlReferrer);

posted @ 2018-03-26 22:06  天际翔龙  阅读(146)  评论()    收藏  举报