在子目录中创建 ASP.Net 应用程序还是 URL 重写?

发布于 2024-12-16 12:12:19 字数 633 浏览 5 评论 0原文

我有一个 ASP.Net 4.0 Web 应用程序运行在:

www.foo.com

客户要求将应用程序移至:

www.foo.com/bar

现在我无法访问 DNS 记录来设置子域。我应该通过 URL 重写来完成此操作还是应该使用虚拟目录?如何将子目录 bar 设置为应用程序根目录?

这里的最佳实践是什么?

更新 我已经创建了一个虚拟目录,但在浏览它时出现此错误

解析器错误消息:在应用程序级别之外使用注册为allowDefinition='MachineToApplication'的节是错误的。此错误可能是由于未将虚拟目录配置为 IIS 中的应用程序而导致的。

更新请参阅我的回答如下

I have an ASP.Net 4.0 web application running on:

www.foo.com

The client has asked that the application be moved to:

www.foo.com/bar

Right now I do not have access to the DNS Records to setup a sub domain. Should I do this with URL Rewriting or should I use a Virtual Directory? How do I set the subdirectory bar as the application root?

What are the best practices here?

UPDATE I have created a virtual directory but get this error when I browse to it

Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.

UPDATE See my answer below

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

揪着可爱 2024-12-23 12:12:19

经过一个小时左右的有趣的互联网搜索后,我是如何让它工作的:

  1. 打开 IIS 管理器。
  2. 右键单击站点并选择“删除”。
  3. 右键单击“默认网站”并选择“添加应用程序”。
  4. 设置虚拟路径“bar”并添加正确的物理路径。

Well after a fun hour or so scouring the interwebs here's how I got it to work:

  1. Open IIS Manager.
  2. Right click on site and select "Remove".
  3. Right click on Default Web Site and select "Add Application".
  4. Set the Virtual Path "bar" and add the proper Physical Path.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文