如何将所有IIS请求路由到我的MVC应用程序? [英] How to route all IIS requests to my MVC app?

查看:77
本文介绍了如何将所有IIS请求路由到我的MVC应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个MVC 3应用程序,该应用程序为客户公司管理业务.部署后,传入的请求应突出显示客户公司的名称;因此, http://hosteddomain.com/Excelsior/Home/Dashboard/3应从客户端Excelsior检索用户的主页.

I'm creating an MVC 3 app that manages business for client companies. When deployed, incoming requests should prominently feature the name of the client company; thus, http://hosteddomain.com/Excelsior/Home/Dashboard/3 should retrieve the home page for a user from client Excelsior.

问题1 :在开发服务器上,此操作正常(localhost:28497/ClientCompany/...),因为我的RouteConstraint查找了公司名称.但是,当我部署它时,如何告诉IIS将所有请求发送到我的应用程序?现在,IIS将查找名为"ClientCompany"的应用.

Question 1: On the development server this works fine (localhost:28497/ClientCompany/...) because my RouteConstraint looks up the business name. However, when I deploy this, how do I tell IIS to send all requests to my app? As it is now, IIS will look for an app named "ClientCompany".

问题2 :有更好的方法吗?例如,使用格式为ClientCompany.hosteddomain.com/SomeAppName/[pages...]的URL.如果是这样,我如何告诉IIS将请求重新映射到我的应用程序,以及如何从MVC应用程序内部获取客户公司的名称?

Question 2: Is there a better way to do this? For example, using URLs of the form ClientCompany.hosteddomain.com/SomeAppName/[pages...]. If so, how do I tell IIS to remap the requests to my app AND how do I get the name of the client company from inside the MVC app?

元问题1 :也许更好的问题1是:如何使我的应用成为IIS的默认网站?

Meta-Question 1: Maybe a better question 1 is how do I make my app be the Default Web Site for IIS?

感谢有识之士 埃里克

推荐答案

关于问题#2,您可以从HttpContext.Current.Request访问原始URL.您可以从那里找到想要的任何东西.

On Question #2, you can get access to the raw url from the HttpContext.Current.Request. You can find out anything you want from there.

我会在IIS中为单个应用程序设置主机标头,然后解析该URL,然后从那里进行任何操作.

I would setup Host Headers in IIS for a single application, then parse the url and do whatever you need to from there.

编辑

唯一需要注册的域名是TLD(顶级域名),所以

The only domain name that needs to be registered is the TLD (Top Level Domain), so

subdomain.tld.com只是您需要为其输入DNS条目然后设置IIS主机标头的子域.

subdomain.tld.com is just a sub domain that you need to make a DNS entry for and then setup the IIS Host Headers.

看看这个: http://technet .microsoft.com/en-us/library/cc753195(WS.10).aspx

请注意,如果我没记错的话,如果您使用的是SSL,主机标头将不起作用.

Note that Host Headers don't work if you are using SSL if I remember correctly.

这篇关于如何将所有IIS请求路由到我的MVC应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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