易截截图软件、单文件、免安装、纯绿色、仅160KB

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


相关文档:

asp.net客户端或服务端验证方式


客户端验证方式:
 protected void Page_Load(object sender, EventArgs e)
    {
       
        if (!IsPostBack)
        {
       &nbs ......

Asp.Net 301重定向的实现(SEO友好,有利于PR值)

网站的重定向,通常用的有 301 和 302,301是永久重定向,是对SEO友好的,有利于保持原域名和新域名之间的PR转移及流量数据等。
Asp.Net 中实现301重定向的代码,也是比较简单的,举个例子:
原来的域名是 www.abc.com, 现在要将对这个域名的访问,全部重定向到 www.zu14.cn;
只需在 需要转向的页面里,
protected void ......

ASP.NET实现在线播放FLV视频件的代码

ASP.NET实现在线播放FLV视频件的代码
 
前台调用代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1&q ......

ASP.NET恢复SqlServer数据库还原失败

在用Asp.net对备份的数据库文件进行还原的时候,有时候会出现下面的错误异常:
[因为数据库正在使用,所以未能获得对数据库的排它访问权。 RESTORE DATABASE 操作异常终止。已将数据库上下文改为 'master'。]
这个时候,自由等待其他进程释放对应权限后,才可还原成功!有没有解决办法呢?我参照【Java】对这个问题的解决 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号