我可以通过子网站的 web.config 文件设置“默认网站”的属性吗? (IIS6)
我在 IIS6 下遇到以下问题。我完全理解这个问题,我只是在寻找最好的解决方案。
我有以下内容:
- 默认网站
- api 服务
- 我们的网站
网站“apiservices”仍在 .NET Framework v2.0 下运行。 网站“ourwebsite”在使用 MVC3 的 .NET Framework v4.0 下运行。
.NET 4.0 中引入的一项新功能(无扩展 URL 处理)由于混合的 .NET 框架版本而给我们带来了一些问题。
如果我访问:
- “我们的网站”->右键单击->属性->虚拟目录选项卡->配置。我发现存在一个映射到 .NET Framework v4.0 aspnet_isapi.dll 的通配符应用程序。 这是正确的,但由于我们的设置还不够。
- 'apiservices' ->右键单击->属性->虚拟目录选项卡->配置。我发现存在一个映射到 .NET Framework v2.0 aspnet_isapi.dll 的通配符应用程序这对于我们的设置来说是正确的,并且不得设置为 4.0,否则会损坏。
现在,这是由于微软的更改而引入的错误: 因为 ASP.NET v4.0 应用程序没有在根级别定义其通配符映射,所以我们的应用程序内部的默认网站、PageMethods 会被获取路由不正确和 404。
最疯狂的部分是什么?如果我转到:
- “默认网站”->右键单击->属性-> “主目录”选项卡 ->配置。然后,从此处将 .NET Framework v4.0 添加到我的通配符应用程序映射中。
- 我单击“确定”。系统会提示我指出我希望将这些更改应用到哪些儿童网站,因为它们都定义了自己的通配符应用程序映射。 我在此指出,我只想将此通配符映射应用于“我们的网站”,而不是“apiservices”
应用此更改可以解决我们的问题。
现在,我想知道,我该如何设置呢?这是web.config文件的工作吗——它能像这样控制上层设置吗?或者这是我们安装程序的自定义操作的工作?
编辑:看起来我需要使用 WIX 来执行此操作。目前,我有下面的代码来在子级别设置通配符映射。我正在探索在根级别设置它而不覆盖“apiservices”通配符映射的方法:
<iis:WebVirtualDir Id="CSWebVirtualDir" Alias="[TARGETCSWEBVDIR]" Directory="CABLESOLVEWEBDIR" WebSite="DefaultWebSite">
<iis:WebApplication Id="CSWebApplication" Name="[TARGETCSWEBVDIR]" AllowSessions="yes" ParentPaths="yes" ScriptTimeout="900" SessionTimeout="60" WebAppPool="CSWebAppPool" ClientDebugging="no" ServerDebugging="no" Isolation="medium">
<iis:WebApplicationExtension Executable="[FRAMEWORKROOT]v4.0.30319\aspnet_isapi.dll" CheckPath="no" Script="yes" Verbs="GET,HEAD,POST" />
</iis:WebApplication>
<iis:MimeMap Id="MIMEXAP" Type="application/x-silverlight-app" Extension=".xap" />
<iis:MimeMap Id="MIMEXAML" Type="application/xaml+xml" Extension=".xaml" />
</iis:WebVirtualDir>
<iis:WebVirtualDir Id="CSWebAPIVirtualDir" Alias="[TARGETCSWEBAPIVDIR]" Directory="CABLESOLVEWEBAPIDIR" DirProperties="CSWebAPIVirtualDirProperties" WebSite="DefaultWebSite">
<iis:WebApplication Id="CSWebAPIApplication" Name="[TARGETCSWEBAPIVDIR]" ParentPaths="yes" AllowSessions="yes" ScriptTimeout="900" SessionTimeout="60" WebAppPool="CSWebAPIAppPool" ClientDebugging="no" ServerDebugging="no" Isolation="medium">
<iis:WebApplicationExtension Executable="[FRAMEWORKROOT]v2.0.50727\aspnet_isapi.dll" CheckPath="no" Script="yes" Verbs="GET,HEAD,POST" />
</iis:WebApplication>
</iis:WebVirtualDir>
I am experiencing the following issue under IIS6. I understand the issue completely, I am just looking for the best solution.
I have the following:
- Default Web Site
- apiservices
- ourwebsite
The website 'apiservices' is running under .NET Framework v2.0 still.
The website 'ourwebsite' is running under .NET Framework v4.0 using MVC3.
A sweet new feature introduced in .NET 4.0, Extensionless URL handling, is causing us some issues because of our mixed .NET framework versions.
If I go to:
- 'ourwebsite' -> right click -> properties -> virtual directory tab -> configuration. I see that there exists a wildcard application mapping to .NET Framework v4.0 aspnet_isapi.dll. This is correct, but not sufficient due to our setup.
- 'apiservices' -> right click -> properties -> virtual directory tab -> configuration. I see that there exists a wildcard application mapping to .NET Framework v2.0 aspnet_isapi.dll This is correct for our setup AND must not be set to 4.0 or it will break.
Now, here is the error introduced due to microsoft's changes: Because the ASP.NET v4.0 Application does not have its wildcard mapping defined at the root level, Default Web Site, PageMethods inside of our application get improperly routed and 404.
The crazy part? If I go to:
- 'Default Web Site' -> right click -> properties -> 'Home Directory' tab -> configuration. And then, from here, add .NET Framework v4.0 to my Wildcard application maps.
- I click OK. I am prompted to indicate which children websites I wish to apply these changes to because they both define their own wildcard application mappings. I indicate here that I only wish to apply this wildcard mapping to 'ourwebsite' and not 'apiservices'
Applying this change resolves our issue.
Now, I am wondering, how do I go about setting this? Is this the job of the web.config file -- can it control upper-level settings like this? Or is it the job of a custom action of our installer?
EDIT: It looks like I need to do this using WIX. Currently, I have the code below to set the wildcard map at the child level. I am exploring ways of setting it at the root level without overwriting 'apiservices' wildcard mapping:
<iis:WebVirtualDir Id="CSWebVirtualDir" Alias="[TARGETCSWEBVDIR]" Directory="CABLESOLVEWEBDIR" WebSite="DefaultWebSite">
<iis:WebApplication Id="CSWebApplication" Name="[TARGETCSWEBVDIR]" AllowSessions="yes" ParentPaths="yes" ScriptTimeout="900" SessionTimeout="60" WebAppPool="CSWebAppPool" ClientDebugging="no" ServerDebugging="no" Isolation="medium">
<iis:WebApplicationExtension Executable="[FRAMEWORKROOT]v4.0.30319\aspnet_isapi.dll" CheckPath="no" Script="yes" Verbs="GET,HEAD,POST" />
</iis:WebApplication>
<iis:MimeMap Id="MIMEXAP" Type="application/x-silverlight-app" Extension=".xap" />
<iis:MimeMap Id="MIMEXAML" Type="application/xaml+xml" Extension=".xaml" />
</iis:WebVirtualDir>
<iis:WebVirtualDir Id="CSWebAPIVirtualDir" Alias="[TARGETCSWEBAPIVDIR]" Directory="CABLESOLVEWEBAPIDIR" DirProperties="CSWebAPIVirtualDirProperties" WebSite="DefaultWebSite">
<iis:WebApplication Id="CSWebAPIApplication" Name="[TARGETCSWEBAPIVDIR]" ParentPaths="yes" AllowSessions="yes" ScriptTimeout="900" SessionTimeout="60" WebAppPool="CSWebAPIAppPool" ClientDebugging="no" ServerDebugging="no" Isolation="medium">
<iis:WebApplicationExtension Executable="[FRAMEWORKROOT]v2.0.50727\aspnet_isapi.dll" CheckPath="no" Script="yes" Verbs="GET,HEAD,POST" />
</iis:WebApplication>
</iis:WebVirtualDir>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们的解决方案是将这些步骤添加到我们的安装指南中。我无法确定简单修改默认网站的方法。
Our solution was to add these steps to our install guide. I was unable to determine a way of simply modifying the Default Web Site.