SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have created usercontrol (.ascx) as a webpart. When I deployed it, I got a prompt for login and 401 error.

The error occurs when I call Me.CreateChildControls().

Help Please.

I created a class that inherits WebPart. Here is my code in VB.

Imports Microsoft.SharePoint.WebPartPages

Public class UserControlWebPart
    Inherits Webpart  
Protected Overrides Sub CreateChildControls()<br>
    Dim control as MyPage = Me.Page.LoadControl(mycontrolpath)<br>
End Sub

Protected Overriedes Sub RenderContents(Byval writer as System.Text.HtmlWriter)<br>
End Sub<br>
End Class

I followed example from this site,; everything is working. I'm rewrite the code in Vb because all my current .ascx are written in vb. This is when I ran into permission issue (note: no permission issue with c#)

share|improve this question

401 means access denied.

Check that the user that you are using to deploy and run your webpart has enough rights.

Also, are you calling CreateChildControls() from OnInit instead of from OnLoad?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.