|
There are several conditions that may cause this issue. Each known condition is presented with a short explanation and a possible workaround.
1. Application Pool Recycling
2. Server Farms or Server Clusters
3. Form Posts
4. Proxy servers and Virus Scanners
Background:
Viewstate represents the state of the page when it was last processed on the server. The contents of the page are stored in a container and moved to and from the server on each request. By default, ASP.NET validates the contents of viewstate to ensure that it has not been tampered. If this validation test fails, an invalid viewstate exception is thrown. Some known issues that cause this test to fail are listed below.
Application Pool Recycling:
IIS 6 will periodically recycle the application pool to maintain the health of the application pool. At the instance when the application pool is being recycled, browser requests may sometimes result in an invalid viewstate error. The fix in this case is to adjust the settings on the application pools so that recycling is less likely to occur at peak periods. This issue represents a bug since the application pool is supposed to gracefully handle this condition.
Server Farms or Server Clusters:
Applications running in a server cluster must have all the machineKey configurations set to the same validationKey. The default autogenerate key cannot be used in a cluster environment. The registry keys responsible for autogeneration are listed here:
HKEY_LOCAL_MACHINE\Software\Microsoft\ASP.NET
HKEY_CURRENT_USER\Software\Microsoft\ASP.NET
When the machineKey is set to AutoGenerate, the key information is stored in the HKEY_CURRENT_USER hive for the account running the process. For W2k3 servers, this is the Network Service account. Otherwise, the account is ASP.NET machine account. When the process launches, ASP.NET will use the HKEY_CURRENT_USER registry key if it is available. If this key is not available, the
HKEY_LOCAL_MACHINE key will be used. If neither registry key exists, the process creates the key in the HKEY_LOCAL_MACHINE hive. If these conditions fail, the process creates a brand new set of keys.
When the application pool is running under a user account, the above keys are not generated leading to an intermittent invalid viewstate error.
The workaround is to use a specific key in the machine.config to prevent automatic key generation on each process start. The key must be exactly 128 bits made up of random characters and inserted into the configuration file on each webserver experiencing the problem.
Form Posts:
Viewstate can only be posted back to the same page. Attempting to post an aspx form to another page will fail with a viewstate invalid exception. This behavior is by design.
One other remedy involves disabling the Machine Authentication Check. Unless, you implement a back up authentication mechanism, you should refrain from this approach. Machine Authentication Checks are important in reducing the attack surface of ASP.NET applications.
Proxy servers and Virus Scanners:
A firewall and/or antivirus software can tamper with the viewstate resulting in an invalid viewstate exception being thrown.
Thanks,
Bimal Kothari
bimal.kothari@gmail.com
|
|
|
|
|
can anyone help me to read the nodes and values of a XML to a multidimensional array.there is only single parent node for my xml page.
Vipin
|
|
|
|
|
Hi Vipin,
You can use a For each statement to read all the nodes in an XmlDocument. the XmlDocument will contain the xml data from a file, i guess. You can do something like this-
XmlDocument xmlDoc = new XmlDocument();
int i=0;
string[] arrString = new string[20];
XmlNode tempNode, xn;
xmlDoc.Load("c:\sample.xml");
xn = doc.DocumentElement;
ForEach(tempNode In xn.ChildNodes)
arrString[i] = tempNode.InnerText;
i++;
Next
doc.Save("c:\sample.xml");
Hope this helps. The code i wrote is not compiled. tell me if gives some error, i will correct it.
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
Anant Y. Kulkarni
|
|
|
|
|
i have three pages in asp.net.
1.from first page(first.aspx) display second page (second.aspx) in newwindow using window.open()
2.then from second page(second.aspx) display third page(third.aspx) in newwindow using window.open() and close window
3.then from third page(third.aspx) close window and refresh first.aspx
Mahendra
|
|
|
|
|
As you close the second window, you have no way of reaching the first window from the third window. You have to get the reference to the first window, and pass it from the second window to the third window before you close the second window.
---
b { font-weight: normal; }
|
|
|
|
|
mbsum wrote: i am not getting solution can u explain me if u have time
thanks
Mahendra
After you have opened the third window, wait for it to load, so that you can get the value of window.opener from the second window to the third window.
Perhaps you should run a script onload in the third window that stored the reference window.opener.opener and then closes the second window.
-- modified at 2:31 Wednesday 9th August, 2006
---
b { font-weight: normal; }
|
|
|
|
|
Hello,
I am making a photoalbum in asp.net (vbcode). All the pictures should be pickedup from particular directory. I have added a datalist with image and also a repeater control also with image and an array. The codes are as follows.
sub getphoto
Dim photo As String() = System.IO.Directory.GetFiles("C:\pravin\b\shkecellphone", "*.jpg")
Dim dir As System.IO.DirectoryInfo = New System.IO.DirectoryInfo("C:\b")
Dim i As Integer = System.IO.Directory.GetParent("C:\b").FullName.Length
Dim ix As Integer = 0
'Image2.ImageUrl = "C:\pravin\b\shkecellphone\p.jpg"
Dim p As New ArrayList
Dim obd As New PagedDataSource
Do While ix > photo.Length
photo(ix) = photo(ix).Substring(i + 1)
' photo(ix) = photo(ix).Replace("\\", "/")
p.Add(photo(ix))
ix += 1
Loop
Image2.ImageUrl = photo(2)
Label1.Text = photo(ix).ToString
'DataList1.DataSource = photo.CopyTo(DataList1.Items)
obd.DataSource = photo
'datalist2.datasource = photo
'even this is not working this also show then the image empty
DataList2.DataSource = dir.GetFiles("*.jpg")
Repeater1.DataSource = dir.GetFiles("*.jpg")
Repeater1.DataBind()
DataList2.DataBind()
End Sub
The Problem is when i am running it I am not able to see the picture, its is able to count and show the same no of image icon and also the path but its all empty.
kindly let me know whats wrong in this code or what is lacking and any other way the datalist item image or repeater image show the images. Pls feel free to ask me if you want to know more about.
Thanks in advance
|
|
|
|
|
I am using javascript to open a popup window on a ImageButton click.
My Page_Load contains this code
btnNew.Attributes.Add("onclick","popNew()");
this is my javascript
<br />
function popNew()<br />
{<br />
window.showModalDialog("popNew.aspx", null,"center:yes;resizable:no;dialogHeight:500px;dialogWidth:410px");<br />
}<br />
When I click on the ImageButton btnNew the first time, the Page_Load for popNew fires. I save the details in the form and I do a Response.Write("<script type='text/javascript'>window.close()</script>");
From the main form when I click the button for the 2nd time or more, the Page_Load for popNew doesnt fire.
I am storing some some data in a hidden asp.net textbox in popNew. I clear the data just before I do window.close() but when I click the button in the main form and come to the popup the data in the textbox still exists.
If I use window.Open(), then I do not have this problem but again I am using modalDialog as I refresh the page from the cs once I know the popup is closed. With window.open my cs code doesnt wait for the popup to close and the refresh takes place before it needs to happen.
Is their something I am missing? What would be an easy solution to this?
Tarakeshwar
MCP, CCIE Q(R&S)
Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes.
!sgub evah t'nseod margorp sihT ?sgub naem ayaddahW
|
|
|
|
|
am in the design view of my default.aspx file, if i click on Tools -> Generate Local Resources , its not active, is there anything am missing?? Am using Visual Web Developer 2005 Express Edition.
Help Please.
Thanks
----------------------------------------------------------------
where there is a will there is a way
|
|
|
|
|
how to handle keyboard events, keypress e.g., of data grid on client side
|
|
|
|
|
You can use a Javascript event PressNewKey on the client side
Rgds,
aLi
|
|
|
|
|
but how? i want to highlight next row on the datagrid form the current row using arrow up & arrow down key.
|
|
|
|
|
How can i link my menu items with javascript code.any help is appreciated.
E-Ramu
|
|
|
|
|
Hi
Is there any article or library to incoperate Electronic Clearing House services in our projects.
http://www.echo-inc.com[^]
Thanks in Advance.
-- modified at 2:44 Tuesday 8th August, 2006
|
|
|
|
|
Hi,
I have a web application and I need to call a different window
application (exe file) from my web application.
Is it possible? How do I do that? Can I transfer parameters to that exe
file from my web application?
Thanks,
Thanh Tri.
Le Thanh Tri
|
|
|
|
|
Use Process.Start()[^] to start running a program
|
|
|
|
|
It doesn't work????
I have already try it. It work easily on Windows Application but in web application, it start process but the new window don't appear.I mean to say when i start process of NODEPADE, it start process but the nodepad window does't appear.
Rgds,
aLi
|
|
|
|
|
Hi,
Iam implementing shoppingcart.In that i placed a Gridview with columns Name,price,picture,checkboxfield(select).
User select the items from the gridview and click on ADDCART Button which is outside of GridView.
when user click ADDCART button,the rows in the gridview for which checkbox field checked that vales iam storing in a datatable.
for this ADDCART button click event i wrote the following code:
int c=0;
for (int i = 0; i < GridView1.Rows.Count; i++)
{
GridViewRow row = GridView1.Rows[i];
bool isChecked = ((CheckBox)row.FindControl("chkSelect")).Checked;
if (isChecked)
c++;
}
Response.Write(c.ToString());
//This code only to check.
Eventhough i checked 2 checkbox fields,and click on ADDCART
The c value is 0.
Anything wrong in the above code.
Or Give me some idea on How to ADD user selected items to CART.
Please help me.
Thanks in advance
|
|
|
|
|
|
Are you manually binding the items to the gridview (i.e. not using a datasourcecontrol)?
If so, make sure your binding is not occuring on postback,
i.e.
if you have something like:
Page_Load
{
BindMyGridView();
}
make if
Page_Load
{
if (!Page.IsPostBack)
BindMyGridView();
}
|
|
|
|
|
hey..
the code works completely fine..
pls check the name of the checkbox u have placed and the name u have given in the FinControl Method is same.
it works fine.
where there is a will there is a way
|
|
|
|
|
OK,
I am about to pull my hair out, and this is why.
I am building a webpage using asp.net (c#), that collects data via a form. The data is saved to a mysql db.
Now I have a ms word document on my pc that is a template. It has certain sections where the data colected from the form needs to be inserted. Now of course a mail merge is the perfect solution but how do i do this?
I would love to have it done on the server, but I have read and searched and cant find any easy way to do, or any way at all for that matter. I thought I found a solution is JSisys's WordReport. But going to there website I noticed it has dissapeared, with no mention. Is there anyway I can do this using asp.net on the server?
I know I can do this manually on my pc, if i just export a text file containing the data from the web form and use that file to perform a mail merge with ms word open, but there must be a way where i can eliminate the manual process of opening word and doing it that way??????
I have looked at automation from a c++ program but I belive this just opens word and automates it this way. And I dont wish to word to open everytime someone submits the form...
Can anyone help me out? It would be so much appreciated I cant explain.
Cheers
|
|
|
|
|
IMHO, to perform mail merge at the server side you'll basically have two options a/ Use the Automation[^], but I don't prefer this way. b/ Use a third party component like Aspose.Word[^].
|
|
|
|
|
The PasswordRecovery uses SMTP configurations specified in web.config. How I do to specify this in runtime? I wish get these parameters from my database instead.
Kind Regards
Jesus is Love! Tell to someone!
|
|
|
|
|
Hi there. You can use the SendingMail event of the control to send the notification email with the settings stored in DB.
|
|
|
|