Shabdar.org
Webshabdar.org
The relative virtual path MyUserControl.ascx is not allowed here error in Web.Config PDF Print E-mail
Written by Shabdar   
Tuesday, 25 November 2008 10:03

Problem

I am trying to add a user control in Web.Config file as below,

 
< controls> 
< add tagPrefix="MyControl" tagName="MyUserControl" src="/MyUserControl.ascx"/> 
< /controls> 
It gives me following error,

 

Configuration Error: The relative virtual path 'MyUserControl.ascx' is not allowed here.

Solution

To resolve this issue, move your WebUserControl from root directory to a sub directory. For example in my case, I would copy MyUserControl.ascx to sub folder "Controls". So my Web.Config entry should look like below.
 
< controls> 
< add tagPrefix="MyControl" tagName="MyUserControl" src= "~/Controls/MyUserControl.ascx"/> 
< /controls> 
~ indicates relative path from root folder.
This is one of the limitation of ASP.Net application. It does not allow you to register user control in Web.Config file unless it's in a subfolder.

Comments/Questions

{mos_fb_discuss:14}
Comments
Add New Search
+/-
Write comment
Name:
Email:
 
Website:
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
Please input the anti-spam code that you can read in the image.
Jeffrey  - Web Programmer |58.170.83.xxx |2009-12-05 06:54:07
Can you add a user control to a web site that is located on another web site by
referencing the domain/full path?
Last Updated on Saturday, 03 January 2009 23:55