且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将ASP.NET Web API应用程序配置为ASP.NET MVC应用程序下的虚拟目录

更新时间:2022-11-06 16:33:41

我认为您的方法存在的问题是尝试在虚拟目录中托管Asp.Net应用程序.相反,您必须添加子应用:

I think the problem with your approach is trying to host an Asp.Net application inside a Virtual Directory. Rather, you must add a child Application:

然后修改根应用程序的web.config以避免配置冲突:

Then modify the web.config of the root application to avoid configuration collisions:

参考:在子应用程序中禁用继承这样,您将能够访问您的子Web API,而无需修改任何C#代码:

This way, you will be able to access your child web api without modifying any c# code: