I swear I have a love hate relationship with Microsoft. This is being thrown only in IE 10.
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/>
Now,
On the #page I have ValidateRequest = "False"
In the Web.config I have httpRuntime requestValidationMode="2.0"
I am NOT using any Ajax or have a ScriptManager
I am checking for PostBack
Removed combobox code but it does use AutoPostBack
Here is my code
Private Sub Page_Init(sender As Object, e As EventArgs) Handles Me.Init
Try
Dim User As New UserRole(Me.SiteID, Master.UserName)
If User.GetLevel(Permissions.Edit) >= Levels.Page Then
Exit Sub
End If
Catch ex As Exception
End Try
Response.Redirect("/Manage/Errors/Unauthorized.aspx")
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Me.IsPostBack = True Then
Exit Sub
End If
Try
Dim Item As New PageBase(Me.PageID)
Me.txtCode.Text = Item.Code
Catch ex As Exception
Master.ShowError("Flex encountered a problem reading this page.")
End Try
End Sub
Private Sub cmbSnippet_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbSnippet.SelectedIndexChanged
If Me.cmbSnippet.SelectedIndex = 0 Then
Exit Sub
End If
Try
Dim Filename As String = String.Format("/Manage/Editors/Text/Scripts/{0}", Me.cmbSnippet.SelectedValue)
Me.txtCode.Text = My.Computer.FileSystem.ReadAllText(Server.MapPath(Filename))
Exit Sub
Catch ex As Exception
End Try
Master.ShowError("Flex encountered a problem reading the snippet.")
End Sub
Private Sub btnOk_Click(sender As Object, e As EventArgs) Handles btnOk.Click
Try
Dim Item As New PageBase(Me.PageID)
Item.Code = Me.txtCode.Text
If Item.Update = True Then
Me.ShowUpdateTime()
Exit Sub
End If
Catch ex As Exception
End Try
Master.ShowError("Flex encountered a problem modifying this page.")
End Sub
Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
Response.Redirect(String.Format("/Manage/Preview.aspx?PageID={0}", Me.PageID))
End Sub
This may or may not solve the issue.
.NET 4 and earlier don't know what IE 10 is. It's not in the list of browsers .NET knows about, so .NET assumes the browser is something that can't handle...well, anything really. Javascript and cookies, and I suspect more, get screwed over. So:
Download this: http://www.hanselman.com/blog/content/binary/App_BrowsersUpdate.zip, which is taken from here:
http://www.hanselman.com/blog/BugAndFixASPNETFailsToDetectIE10CausingDoPostBackIsUndefinedJavaScriptErrorOrMaintainFF5ScrollbarPosition.aspx,
which is referenced from here: IE10 User-Agent causes ASP.Net to not send back Set-Cookie (IE10 not setting cookies)
Extract the files and put them in your application's App_Browser directory. Rebuild and see if that works.
Related
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
I am attempting to add the text that a user types into the textbox 'textMain' to a cookie. I am trying to do this so there is no need to click a 'Save' button. Therefore a user could type a sentence and then close the browser and it would be saved. Here is the VB code; done on the load handler and the unload handler.
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not IsPostBack Then
If Request.Cookies("content") IsNot Nothing Then
textMain.Text = Request.Cookies("content").Value.ToString
End If
End If
End Sub
Protected Sub Page_Unload(sender As Object, e As EventArgs) Handles Me.Unload
'' If Request.Cookies("content") Is Nothing Then
Dim contentCookie As New HttpCookie("content")
contentCookie.Value = textMain.Text
contentCookie.Expires = DateTime.MaxValue
Response.Cookies.Add(contentCookie)
'' End If
End Sub
The exception comes on the Respinse.Cookies.Add(contentCookie) line.
Thanks!
I have an asp.net page that loads two controls, Control A and Control B. Control A has some generic form submit and clear buttons that trigger click events in its' own code behind which use reflection to call the update function in Control B which has a few input fields. I have debugged this and everything seems to be in order, however; when the update function in control B is called the input fields are not returning a value when using inputname.text or me.inputname.text. Does anyone have any ideas why this is not working? Any guidance would be appreciated.
This is the code in Control A's codebehind which calls the update method in Control B's code behind
Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSave.Click
Try
Dim lctlControl = Session("SelectedQstnCtl")
Dim methodObj = lctlControl.GetType().GetMethod("UpdateGenInfo", BindingFlags.NonPublic Or BindingFlags.Instance)
' Execute UpdateGenInfo method to update the data
methodObj.Invoke(lctlControl, Nothing)
Catch ex As Exception
'TODO: check for concurrency error here
End Try
End Sub
This is the update function in Control B that is being called. The session values are being passed, but the form fields are not.
Protected Sub UpdateGenInfo()
Dim lclUtil As New clUtility
Dim genInfo As New clGenInfo
Try
Dim dt As Integer
'Update Data for 1-2
dt = genInfo.UpdateGenInfo_E1_01_02(Session("ConnStrEP"), Me.varLastUpdate, Session("AppNo"), Session("RevNo"), _
Me.txtPrName.Text, Me.txtPrAddr1.Text, Me.txtPrAddr2.Text, _
Me.txtPrCity.Text, Me.txtPrState.Text, Me.txtPrZip.Text)
Catch ex As Exception
'Display error
lclUtil.DisplayMsg(Me.lblErrMsg, String.Format("Error Location: Sub LoadGenInfo (ctlE1_01_02) {0}", ex.Message))
End Try
End Sub
The most likely cause is that the control instance stored in the session is not the control instance on the current page. For example, if you're storing the control instance in the session when the page is first loaded, and retrieving it on post-back, it will be a different instance.
If you can't give Control A a direct reference to Control B, then change your code to store the reference in the Page.Items collection:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Page.Items("SelectedQstnCtl") = TheSelectedQstnCtl
End Sub
Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSave.Click
Dim lctlControl = DirectCast(Page.Items("SelectedQstnCtl"), YourControlClass)
lctlControl.UpdateGenInfo()
End Sub
I see you are using reflection which might be an overkill for that task.Try referencing the method in the control directly.Make then method UpdateGenInfo public and then reference it like this.
Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSave.Click
Try
Dim lctlControl = CType(Session("SelectedQstnCtl"),YourControlClass)
lctlControl.UpdateGenInfo()
Catch ex As Exception
End Sub
Public Function UpdateGenInfo()
'your code here
Catch ex As Exception
End Try
End Function
This way you can easily trace where your values are getting lost.Let me know how it goes.
Try yet another simple approach working demo here
In control a
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim testb1 = CType(Me.NamingContainer.FindControl("testb1"), testb)
testb1.UpdateGenInfo()
End Sub
In control b
Public Function UpdateGenInfo()
Try
Dim a = Me.TextBox1.Text
Catch ex As Exception
End Try
End Function
Aspx Parent Page
<uc1:testa ID="testa1" runat="server" />
<uc2:testb ID="testb1" runat="server" />
The controls in testb are in an update panel.Try this and let me know if this works.
Everything was working fine. Then I added the Global.asax and suddenly got this error:
Line: 4723
Error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
Details: Error parsing near 'eeCtrl_Data = null;|
<%# Application Language="VB" %>
<script runat="server">
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application startup
End Sub
Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application shutdown
End Sub
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when an unhandled error occurs
End Sub
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when a new session is started
End Sub
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when a session ends.
' Note: The Session_End event is raised only when the sessionstate mode
' is set to InProc in the Web.config file. If session mode is set to StateServer
' or SQLServer, the event is not raised.
End Sub
Protected Sub Application_BeginRequest(ByVal sender As Object, ByVal e As System.EventArgs)
HttpContext.Current.Items("renderStartTime") = DateTime.Now
End Sub
Protected Sub Application_EndRequest(ByVal sender As Object, ByVal e As System.EventArgs)
Dim startTime As DateTime = CType(HttpContext.Current.Items("renderStartTime"), DateTime)
Dim renderTime As TimeSpan = DateTime.Now - startTime
HttpContext.Current.Response.Write("<!-- Render Time (in milliseconds): " & renderTime.TotalMilliseconds.ToString & " -->")
End Sub
Try commenting out this line and see if that fixes it.
HttpContext.Current.Response.Write("<!-- Render Time (in milliseconds): " & renderTime.TotalMilliseconds.ToString & " -->")
HTH.
This is not elegant, but it works for my needs (thankfully this is an internal app). It's a two-part solution. One is for the postbacks that occur due to an UpdatePanel postback. The other is for regular postback.
I'd rather not close this thread, because I think better solutions can be presented.
could anybody advice me, are there any approaches to calculate the methods execution time in asp.net page?
ASP.Net Trace doesn't suit me since it ignores ajax partial postbacks though just they are the tight place.
I have the page event which for some unknown reason executes slowly. Since the logic and event execution chain is rather complicated, I still unable to merely determine the culprit in debugger.
I'd like to measure the execution time of each method throughout the page, but I still see no way but insert redundant code lines (like timeBegin = DateTime.Now.... timeEnd=DateTime.Now = timeBegin etc) in the beginning and ending of each method. It seems to be ugly approach, does anybody know how to do it automatically? Are there tools which measure the methods execution time available?
I am not 100% sure the below works in all cases. So far it does though. Note that Context.Session.Item("CURRENT_WEB_USER") is where I store the current user, and is therefore not readily available as part of the asp.net session variables.
The code hereunder is in replacement of Global.aspx that allows both full page timing and timing of developer code.
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Sub Application_AcquireRequestState(sender As Object, e As System.EventArgs)
If HttpContext.Current Is Nothing Then Return
If HttpContext.Current.Session Is Nothing Then Return
If TypeOf HttpContext.Current.CurrentHandler Is Page Then
If Not Context.Items.Contains("Request_Start_Time") Then
Dim MyPage As Page = HttpContext.Current.CurrentHandler
AddHandler MyPage.Init, AddressOf PageInitEncountered
AddHandler MyPage.Unload, AddressOf PageUnloadEncountered
Context.Items.Add("Request_Start_Time", DateTime.Now)
Dim User As String = Context.Session.Item("CURRENT_WEB_USER")
Context.Items.Add("Request_User", User )
End If
End If
End Sub
Sub Application_ReleaseRequestState(sender As Object, e As System.EventArgs)
If HttpContext.Current Is Nothing Then Return
If TypeOf Context.CurrentHandler Is Page Then
Dim Page As Page = Context.CurrentHandler
Dim StartDate As Date = Context.Items("Request_Start_Time") : If StartDate = Nothing Then Return
Dim EndDate As Date = Now
Dim StartProc As Date = Context.Items("Page_Init")
Dim EndProc As Date = Context.Items("Page_Unload")
Dim User As String = Context.Items("Request_User")
LogEntry(StartDate, EndDate, StartProc, EndProc, User, Context.Request.Url.ToString)
End If
End Sub
Public Sub PageInitEncountered(sender As Object, e As System.EventArgs)
Context.Items.Add("Page_Init", DateTime.Now)
End Sub
Public Sub PageUnloadEncountered(sender As Object, e As System.EventArgs)
Context.Items.Add("Page_Unload", DateTime.Now)
End Sub
Public Sub LogEntry(StartDate As Date, EndDate As Date, StartProc As Date, EndProc As Date, User As String, PageURL As String)
System.Diagnostics.Debug.WriteLine(" (" & LogEntry.RequestMs & " - " & LogEntry.DurationMs & ") (" & User & ") " & PageURL)
End Sub
This may not be what you are looking for, but RedGate has a product called Performance Profiler that does exactly that. They do have a 15 day trial so you can even download it and try it out on your current issue. IMHO, it's worth every penny.
You can use asp.net performance counters and other things also. But that will not measure a page speed but they will measure a over all application performance.