i am geting error- Requested Url: /test2/default.aspx and Description: HTTP 404 on page <--->agter login page (clivk button) it is not reaching at same page. my webpagename is-> webform1.aspx . can any body solve this problem plz
i am using this code in button click
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If ValidateUser(TextBox1.Text, TextBox2.Text) Then
FormsAuthentication.Initialize()
Dim strRole As String = AssignRoles(txtUsername.Text)
Dim fat As FormsAuthenticationTicket = New FormsAuthenticationTicket(1.0, TextBox1.Text, DateTime.Now, DateTime.Now.AddMinutes(20), True, strRole, FormsAuthentication.FormsCookiePath)
Response.Cookies.Add(New HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(fat)))
Response.Redirect(FormsAuthentication.GetRedirectUrl(TextBox1.Text, False))
Else
Response.Write("test")
End If
End Sub
Private Function assignroles(ByVal assign As String) As String
If TextBox1.Text = "arun" Then
Return "bigboss"
Else
Return String.Empty
End If
End Function
and in global.axac coading is
Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs)
If Not (HttpContext.Current.User Is Nothing) Then
If HttpContext.Current.User.Identity.IsAuthenticated Then
If TypeOf HttpContext.Current.User.Identity Is FormsIdentity Then
Dim fi As FormsIdentity = CType(HttpContext.Current.User.Identity, FormsIdentity)
Dim fat As FormsAuthenticationTicket = fi.Ticket
Dim astrRoles As String() = fat.UserData.Split("|"c)
HttpContext.Current.User = New GenericPrincipal(fi, astrRoles)
End If
End If
End If
End Sub
and in web.config file coading
<authentication mode="Forms">
<forms name=".arun" loginUrl="WebForm1.aspx" protection="All" timeout="60" path="c:/documents and settings/vinay/cookies"/>
</authentication>
<authorization>
<allow users="*"/>
</authorization>
and blow of caading before </configuration>
<location path="test2/login.aspx">
<system.web>
<authorization>
<allow users="arun"/>
<allow roles="bigboss"/>
</authorization>
</system.web>
</location>