ASP.NET Routing for URLRewriting with QueryStrings
In the last post I showed how to use the ASP.NET 3.5 Routing Engine
for URLRewriting purposes. I want to go further in this post by adding
the ability to add variables into a route path and forward and append
query string variables to the destination Web Form request.
A route can contain one or more variables expressed by its {name}.
RouteTable.Routes.Add(
new
Route(
"articles/{id}"
,
new
devcoach.Web.RoutingPageHandler()));
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
Inside of the RoutingHandler we can iterate through the variables by
accessing them by the RouteData property on the parameter passing the
RequestContext:
var queryString = new
StringBuilder("?"
);
foreach
(var aux in
requestContext.RouteData.Values)
{
queryString.Append(
requestContext.HttpContext.Server.UrlEncode(aux.Key));
queryString.Append("="
);
queryString.Append(
requestContext.HttpContext.Server.UrlEncode(
aux.Value.ToString()));
queryString.Append("&"
);
}
queryString.Remove(queryString.Length - 1, 1);
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0e
相关文档:
前几篇文章介绍了几个国外的.NET CMS,今天就介绍一下国内在ASP.NET平台中比较有特色的pageadmin cms(网址:http://www.pageadmin.net),这个系统并未走传统标签+HTML的路线,直接采用可视化的div+css组合功能模块的设计,大大提供了系统的易用性,下面介绍一下这个系统:
PageAdmin网站内 ......
在用Asp.net对备份的数据库文件进行还原的时候,有时候会出现下面的错误异常:
[因为数据库正在使用,所以未能获得对数据库的排它访问权。 RESTORE DATABASE 操作异常终止。已将数据库上下文改为 'master'。]
这个时候,自由等待其他进程释放对应权限后,才可还原成功!有没有解决办法呢?我参照【Java】对这个问题的解决 ......
//连接数据库
string myStr = CODE.DbHelperSQL.connectionString;
SqlConnection myConn = new SqlConnection(myStr);
myConn.Open();
&nbs ......
asp.net ajax学习笔记
一、 登堂入室——基本概念
http://blog.csdn.net/soldierluo/archive/2009/11/18/4830758.aspx
二、 小试身手——第一个Ajax程序
http://bl ......
asp.net中使用基于角色role的Forms验证,大致经过几下四步:
1.配置系统web.config
timeout="20" path="/" />
其中 表示本应用程序采用Forms验证方式。
1). 标签中的name表示指定要用于身份验证的 HTTP Cookie。默认情况下,name 的值是 .ASPXAUTH。采用此种方式验证用户后,以此用户的信息建立一个FormsAuthenticati ......