I need to check for allow anonymous in ASP.NET Web Forms page and on OWIN middleware.
For ASP.NET Web Forms page, I found the following thread in StackOverflow which works great:
In my case, I need to convert the code to VB.NET, so it becomes:
Dim principal = New GenericPrincipal(New GenericIdentity(String.Empty, String.Empty), New String() {})
Dim isAllowAnonymous = UrlAuthorizationModule.CheckUrlAccessForPrincipal(Page.AppRelativeVirtualPath, principal, Context.Request.HttpMethod).ToString()
And on OWIN middleware, I need to tweak the above a little bit, so it becomes:
Dim principal = New GenericPrincipal(New GenericIdentity(String.Empty, String.Empty), New String() {})
Dim isAllowAnonymous = UrlAuthorizationModule.CheckUrlAccessForPrincipal(context.Request.Uri.AbsolutePath, principal, context.Request.Method)
No comments:
Post a Comment