asp.net中的URL重写问题 [英] URL Rewiting Issue in asp.net

查看:73
本文介绍了asp.net中的URL重写问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在`web.config`中写了以下几行来重写网址。



1)重写url =^ / Results /(。+)/( 。+)/图片to =〜/ Directory.aspx?l = $ 1& t = $ 2& i = 1processing =stop/>



2)重写url =^ / Results /(.+)/(.+)$to =〜/ Directory.aspx?l = $ 1& t = $ 2processing =stop/>



3)重写url =〜/ Results /(.+)/ Imagesto =〜/ Directory.aspx?l = $ 1& i = 1 processing =stop/>



里面`Directory.aspx.cs`:



string Location = string.IsNullOrEmpty(Request.QueryString [l])? :Request.QueryString [l];



string TextPhrase = string.IsNullOrEmpty(Request.QueryString [t])? :Request.QueryString [t];



bool WithImages = string.IsNullOrEmpty(Request.QueryString [i])? false:true;



现在:当我通过提供适当的查询字符串向Directory.aspx页面发送请求时。

第1点和2工作正常,但当我在第3点发送查询字符串请求到完全填充条件时,它似乎没有工作,`Dictionary.aspx.cs`处理查询字符串,如



http://werbsiteaddress.com/Results/US/Images



Location = string.IsNullOrEmpty(Request.QueryString [l ])? :Request.QueryString [l]; // US



TextPhrase = string.IsNullOrEmpty(Request.QueryString [t])? :Request.QueryString [t]; //图片



bool WithImages = string.IsNullOrEmpty(Request.QueryString [i])? false:是的; // false



请帮帮我,如果我遗失了什么请告诉我。



谢谢。

解决方案

1& t =


2& i = 1processing =stop/>



2)重写url =^ / Results /(.+)/(.+)


to =〜/目录的.aspxΔL=

I have written below lines in `web.config` for url rewriting.

1) rewrite url="^/Results/(.+)/(.+)/Images" to="~/Directory.aspx?l=$1&t=$2&i=1" processing="stop" />

2) rewrite url="^/Results/(.+)/(.+)$" to="~/Directory.aspx?l=$1&t=$2" processing="stop" />

3) rewrite url="~/Results/(.+)/Images" to="~/Directory.aspx?l=$1&i=1" processing="stop" />

Inside `Directory.aspx.cs`:

string Location = string.IsNullOrEmpty(Request.QueryString["l"]) ? "" : Request.QueryString["l"];

string TextPhrase= string.IsNullOrEmpty(Request.QueryString["t"]) ? "" : Request.QueryString["t"];

bool WithImages = string.IsNullOrEmpty(Request.QueryString["i"]) ? false : true;

Now: when I send requests to `Directory.aspx` page, by providing appropriate query strings.
point 1 and 2 are working fine but when I send request with query strings to full fill condition in point 3, it does not seem to be working and `Dictionary.aspx.cs` processes the query strings like,

http://werbsiteaddress.com/Results/US/Images

Location = string.IsNullOrEmpty(Request.QueryString["l"]) ? "" : Request.QueryString["l"]; // US

TextPhrase= string.IsNullOrEmpty(Request.QueryString["t"]) ? "" : Request.QueryString["t"]; // Images

bool WithImages = string.IsNullOrEmpty(Request.QueryString["i"]) ? false : true; // false

Please help me out and let me know if I am missing something.

Thanks.

解决方案

1&t=


2&i=1" processing="stop" />

2) rewrite url="^/Results/(.+)/(.+)


" to="~/Directory.aspx?l=


这篇关于asp.net中的URL重写问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆