The referenced file '/Test/Test.ascx' is not allowed on this page.

I created a new sp2013 project and have an aspx page where I'm loading the user control called Test.ascx. The user control is created under /controltemplates under 15 hive.

The user control file structure is - /controltemplates/Test/Test.ascx

In my default.aspx I'm loading the user control with this path -

<%@ Register Src="~/Test/Test.ascx" TagName="TestUserControl" TagPrefix="Demo" %>

I get the error as : The referenced file '/Test/Test.ascx is not allowed on this page.

I added the folder under safe control in web.config and I did IIS reset but still get this error. Don't know what else can be done here
bujjigaduAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rainer JeschorCommented:
Hi,
you should reference this:

<%@ Register Src="~/_CONTROLTEMPLATES/Test/Test.ascx" TagName="TestUserControl" TagPrefix="Demo" %>

Open in new window


(including the controltemplates virtual directory.

HTH
Rainer
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bujjigaduAuthor Commented:
I gave the complete path in web.config file but now I get parse error saying file does not exist in my aspx page where I'm loading the control

This is how I'm referencing in my aspx page to load user control

~/_controltemplates/Test/Test.ascx
0
bujjigaduAuthor Commented:
If I remove _ infront of controltemplates then I get message that this page is not allowed error message.  controltemplates virtual folder created by default in visual studio when I add new user control.

Not sure how to reference in web.config and in my aspx page where I want to load the user control, please clarify
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SharePoint

From novice to tech pro — start learning today.