Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# URL重写子字符串_C#_Asp.net_Url Rewriting - Fatal编程技术网

C# URL重写子字符串

C# URL重写子字符串,c#,asp.net,url-rewriting,C#,Asp.net,Url Rewriting,如何在重写配置中对请求url进行子串 例如: www.domain.com/some request)->www.domain.com/some request 只需从url末尾删除一个字母 编辑: 我希望能够从url重写模块配置中执行此操作,如下所示: <rule name="Redirect to HTTPS" stopProcessing="true"> <match url="(.*)" /> <conditions><add input

如何在重写配置中对请求url进行子串

例如:
www.domain.com/some request)
->
www.domain.com/some request

只需从url末尾删除一个字母

编辑: 我希望能够从url重写模块配置中执行此操作,如下所示:

<rule name="Redirect to HTTPS" stopProcessing="true">
  <match url="(.*)" />
  <conditions><add input="{HTTPS}" pattern="^OFF$" /></conditions>
  <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
</rule>

像这样:

string url = "www.domain.com/some-request)";
string sub = url.Substring(0, url.Length - 1);

或者,如果您知道最后一个字符始终是
,只需执行以下操作:

"www.domain.com/some-request)".TrimEnd(')');

如何使用Asp重写配置而不是从中执行此操作code@ThomasOwers你能为你的问题提供一些背景吗。为什么需要在配置中执行此操作?来自哪里的请求格式不正确?当然问题出在生成这些请求/URL的内容上了?这是一个SEO问题,每个页面上的规范链接都有轻微的错误,现在我们正在让爬虫在请求的末尾添加一个
,从而得到404。最初的问题已经解决,但是很多爬虫程序都有格式错误的链接cachedIt,在这种情况下,这听起来并不是什么问题。您需要以某种方式强制爬虫刷新其缓存的链接。开始寻找的地方。