我正在尝试从表单中重写网址:
https://example.com/about
Run Code Online (Sandbox Code Playgroud)
到形式
http://example.com/about
Run Code Online (Sandbox Code Playgroud)
使用IIS7 URL重写:
<!-- http:// to https:// rule -->
<rule name="ForceHttpsBilling" stopProcessing="true">
<match url="(.*)billing/(.*)" ignoreCase="true" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="false" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}{REQUEST_URI}" />
</rule>
<!-- https:// to http:// rule -->
<rule name="ForceNonHttps" stopProcessing="true">
<match url="(.*)billing/(.*)" ignoreCase="true" negate="true" />
<conditions>
<add input="{SERVER_PORT}" pattern="^443$" />
</conditions>
<action type="Redirect" redirectType="Found" url="http://{HTTP_HOST}{REQUEST_URI}" />
</rule>
Run Code Online (Sandbox Code Playgroud)
我不知所措; 我一直在浏览网页上的例子,并尝试我能想到的每一种语法.我简单地指定重写规则似乎没有工作,在所有的任何HTTPS请求,就好像所有的https://请求都平了无形的重写引擎.
规则工作正常; 见下面的答案.
我正在使用IIS7 UrlRewrite模块.我在web.config <system.webServer><rewrite>部分设置了规则.我想知道是否有一种方法可以在一个外部xml文件而不是web.config文件中定义规则.谢谢.
我在根据查询字符串参数重定向到另一个URL时遇到一些问题.我想将输入www.domain.com/signup.aspx?p=1的用户重定向到:
www.domain.com/signup
<rule name="Signup Redirect 1" stopProcessing="true">
<match url="signup\.aspx\?p=1" />
<conditions logicalGrouping="MatchAll" />
<action type="Redirect" url="signup" redirectType="Temporary" />
</rule>
Run Code Online (Sandbox Code Playgroud)
现在,当他们进入www.domain.com/signup.aspx?p=2时,他们必须去:
www.domain.com/signup/promocode
<rule name="Signup Redirect 2" stopProcessing="true">
<match url="signup\.aspx\?p=2" />
<conditions logicalGrouping="MatchAll" />
<action type="Redirect" url="signup/promocode" redirectType="Temporary" />
</rule>
Run Code Online (Sandbox Code Playgroud)
以上规则不起作用.这样做的正确方法是什么?提前致谢.
GR
马亭
我有一个布局页面和一些使用它的页面.但我想在一些使用它的子页面上实现导航控件.所以我想使用另一个嵌套布局页面.这可能吗?
我在底部主布局中渲染了一个部分.这通常是在呈现时在页面底部呈现javascript的部分.在View和_partial视图中定义该部分.页面呈现时,它从页面视图呈现部分,但不从_partial视图呈现.
如何将_partial视图中定义的部分渲染为主布局?
我在C#中有一个应用程序列表.我希望尽可能多地同时完成这项工作.但是我需要能够控制并行任务的最大数量.
根据我的理解,这可以通过ThreadPool或任务来实现.我使用哪一个有区别吗?我主要担心的是能够一次控制多少个线程处于活动状态.
我需要对我网站上的所有图像使用CDN.因此,我决定使用IIS Url重写模块,因为手动编辑我的所有网站视图 - 这对我来说是不可能的.
所以我为IIS制定了规则,例如:
<rule name="cdn1" stopProcessing="true">
<match url="^Content/Images.*/(.*\.(png|jpeg|jpg|gif))$" />
<action
type="Redirect"
url="http://c200001.r9.cf1.rackcdn.com/{ToLower:{R:1}}"
redirectType="Permanent" />
</rule>
Run Code Online (Sandbox Code Playgroud)
它工作,但你可以看到有使用重定向类型(301永久).我认为它会影响网站性能.也许可以编辑Request.Output来替换图像URL?
请建议,我如何使用CDN图像,不编辑我的视图,避免重定向?
任何帮助将不胜感激
我试过了:
1)我先尝试空字符串:
<action type="Redirect" url="" redirectType="Permanent" appendQueryString="false" />
Run Code Online (Sandbox Code Playgroud)
结果:
HTTP 500.52 - URL Rewrite Module Error.
The substitution URL for the current action cannot be empty.
Run Code Online (Sandbox Code Playgroud)
2)也许我应该省略url属性:
<action type="Redirect" redirectType="Permanent" appendQueryString="false" />
Run Code Online (Sandbox Code Playgroud)
相同的结果:
HTTP 500.52 - URL Rewrite Module Error.
The substitution URL for the current action cannot be empty.
Run Code Online (Sandbox Code Playgroud)
3)ASP.NET方式怎么样:
<action type="Redirect" url="~" redirectType="Permanent" appendQueryString="false" />
Run Code Online (Sandbox Code Playgroud)
尝试重定向到{APP_ROOT}/~.
4)最后一次尝试:
<action type="Redirect" url="/" redirectType="Permanent" appendQueryString="false" />
Run Code Online (Sandbox Code Playgroud)
正如所料,它重定向到服务器的根目录......
我想找一些干净的通用解决方案.(我不能用一些具体的东西/myCurrentAppPath.)
这里只是一些背景信息.我目前正在使用WinHost共享主机,并进行以下设置
Shared IIS
|______Main Primary MVC3 web app (uses NHibernate & Castle.Windsor for ORM)
|_______ Child MVC3 web app (not using NHibernate nor Castle.Windsor as it does not need database access)
Run Code Online (Sandbox Code Playgroud)
在WinHost中,它允许我设置应用程序的起点,所以我可以
/ <= for primary app
/child <= for the child app
Run Code Online (Sandbox Code Playgroud)
每个应用程序都有自己的web.config,所以它就像
/web.config
/child/web.config
Run Code Online (Sandbox Code Playgroud)
好吧,令我惊讶的是,即使将/ child文件夹设置为应用程序起点,它似乎也不会与父主Web应用程序隔离,因为当我尝试加载子应用程序时,我得到了臭名昭着的错误
无法加载文件或程序集"Castle.Windsor"或其依赖项之一.该系统找不到指定的文件.
我尝试通过将NHibernate相关库转储到/ child/bin文件夹来解决这个问题,但这只会让事情变得更糟,因为我还需要在子应用程序中设置额外的NHibernate配置,即使子应用程序不需要数据库访问.
那么是否有某个设置(例如web.config)我可以强制将子应用程序与父应用程序隔离?
我认为,最后的办法是放弃子网页应用,并将其转换为主要主要网络应用下的"区域",但这并不理想,因为这两个网络应用根本没有相互关联,定位不同的观众等
注意:它不应该是路由问题的情况,因为两个原因1. WinHost将/ child文件夹设置为应用程序起点2.在主Web应用程序下,我已经忽略了RegisterRoutes()中的子项
routes.IgnoreRoute("child");
routes.IgnoreRoute("{folder}/{*pathinfo}", new { folder = "child" });
Run Code Online (Sandbox Code Playgroud)
好吧,经过3个小时的工作,我不知所措.任何建议都非常感谢.如果您需要查看任何配置,请告诉我.先感谢您!
SQL Server的散列函数HASHBYTES的输入限制为8000字节.
你如何散列更大的字符串?
iis-7 ×6
iis ×2
razor ×2
web-config ×2
asp.net-mvc ×1
c# ×1
cdn ×1
https ×1
sql-server ×1
sqlclr ×1
t-sql ×1