I Have 2 Pages of ASP V4.5 which are Login.aspx as a starting page and contentMainpage.aspx. It's working when I've tested on debug mode in visual studio 2012, but when I try to deploy it on IIS the button log in is not responding redirect to another page. The problem can be on web configuration I try to google it for 2 days and can not get the solution right. Please help. here the code bellow:
Imports PurchaseOrderList.Class1
Public Class Login
Inherits System.Web.UI.Page
Dim abmPO As New ServiceReference1.Service1SoapClient
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Session("LoginName") = ""
End Sub
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
If IsPostBack Then
Dim LoginAutentif As New PurchaseOrderList.Class1
If (LoginAutentif.ValidatePassword(Trim(TxtLoginName.Text), Trim(TxtPassW.Text))) = 0 Then
LblErrorMessage.Visible = True
LblErrorMessage.Text = "Invalid User Name or User Password"
Exit Sub
Else
If (Response.IsClientConnected) Then
Response.Redirect("~/PurchaseOrderHeaders.aspx", False)
Session("LoginName") = TxtLoginName.Text
End If
End If
End If
Catch ex As Exception
End Try
End Sub
End Class
Maybe try to "return Response.Redirect". I had this problem in MVC5.
Your issue is most likely to do with this line:
If (Response.IsClientConnected) Then
Quick google suggests there may be a few issues with IIS7/7.5 and using this property. Also I don't think it's really necessary here, it would make more sense being used in a long running routine to detect a client disconnect or timeout.
Try changing you button click to the following and see how you go.
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
If IsPostBack Then
Dim LoginAutentif As New PurchaseOrderList.Class1
If (LoginAutentif.ValidatePassword(Trim(TxtLoginName.Text), Trim(TxtPassW.Text))) = 0 Then
LblErrorMessage.Visible = True
LblErrorMessage.Text = "Invalid User Name or User Password"
Exit Sub
Else
Session("LoginName") = TxtLoginName.Text
Response.Redirect("~/PurchaseOrderHeaders.aspx", True)
End If
End If
Catch ex As Exception
End Try
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.