开发者

Url routing and web.config of nested folder

I'm using URL routing (with WebForms) in the following format:

http://host/project/{projectid}/{pageName}

Another option is that the user is refering to a subapplication:

http://host/project/{projectid}/{application}/{pageName}

The subapplication isn't a new web application, simply a virtual directory.

My subapplication does have a web.config, which contains some specific appsettings/connstrings.

Everything works fine without the URL routing.

However when I request an URL in the routed form the web.config of the subapplication isn't processed and I get a null reference on all of the appsettings/connstrings (through ConfigurationManager).

Here's the code in my custom handler:

string path = String.Format(_pagesFormat, application, pageName);   
return (IHttpHandler) BuildManager.CreateInstanceFromVirtualPath(path, typeof(Page));

It works if I would change开发者_如何学运维 my route to http://host/{application}/{projectid}/{pageName}

This probably triggers IIS to load the web.config of the virtual directory as well.

Can I somehow force the settings of the nested web.config to be loaded?

EDIT:

This person has a similar problem:

http://forums.asp.net/p/1452479/3317775.aspx

Any ideas?


For some reason the system.web tag and a few other tags are being processed by the
web.config (that resides in the virtual directory).

I've decided to put my application settings and connection string settings into two separate files in the root:

  • web.config in the root (IS, compilation, handler configuration)
  • web.AppSettings.config in the root
  • web.Connections.config in the root

  • web.config per virtual directory (user control, masterpage configuration)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜