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, http://www.codeproject.com/KB/sharepoint/SharepointWebPart.aspx; 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#)

1 Answer 1


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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.