开发者

ASP.NET : How to indicate a file outside web directory when Relative URI is expected?

开发者 https://www.devze.com 2023-03-28 02:24 出处:网络
It is possible to create or emulate a virtual directory using C# for load controls (ascx) from a directory outside my web application scope?

It is possible to create or emulate a virtual directory using C# for load controls (ascx) from a directory outside my web application scope?

Im trying :

 UserControl newU开发者_开发百科serControl = (UserControl)LoadControl( @"D:\" + ascxFileName);

Obviously I get runtime exception as the follow : 'D: \ ClaimOutputs \ SolicitudDatoIncorrecto_6.ascx' is not a valid virtual path.

Thanks


You will need to add a virtual directory in your IIS site that points to the other physical location.

There are a lot of security reasons why you can't just directly reference files outside of the directory structure your app is running in.

UPDATE:
Can you create a virtual directory in IIS with C#? yes. IIS does have an API. Creating Virtual directory in IIS with c#

However, the user the site runs under should never have the rights necessary to do that due to security concerns. You could set it up as a build process, provided you have the rights necessary to do this.

0

精彩评论

暂无评论...
验证码 换一张
取 消