Error de ASP.Net al inicializar la sesión

I am using an form, and included on the form is a standard textarea. It's not an asp control, just a standard textarea control (No runat=server). I need to do this because I manipulate it with jQuery. For some reason, when the form is posted, I get "Error Initializing Session".

I get a "Page cannot be displayed" if I run it from within Visual Studio's debugger.

I get this error, no matter what I type in the textarea, and cannot find out what line it is occuring on. It's almost like it is occurring somewhere other than in code. It's like Session State is getting confused.

I have tried this, with no luck:


<textarea style='width:100%;' rows='10' cols='50' id="textArea" name="textArea"></textarea>

Código detrás:

if (IsPostBack) {
    foreach(string key in Request.Form) {
        Response.Write("<br />" + key + " = " + (Request.Form[key].ToString()));

Same error, and no output. I have checked the logs, and nothing. There is nothing else on the form. It's very simple as posted.

preguntado el 01 de febrero de 12 a las 04:02

Your session error likely has no connection with the textarea or the form (I can't imagine a scenario where it would) - but I don't see enough info to help you. On another note: make one change at a time to avoid getting distracted by unrelated errors. Use version control to be able to easily branch and undo changes. -

I use version control, but thanks for the advice. The issue was: this was a new file, with very limited code. Searching for "Error Initializing Session" had limited results. The problem was when I added html to the textbox. I tried ValidateRequest="false" but that didn't work for some reason. I had to escape the text with JavaScript before submission using escape($('#textArea').val()). Another noteworthy point: You're right--it had nothing to do with the textbox itself. I converted it to an asp:TextBox and it worked just fine. -

I sense sarcasm in that last textbox part. I still can't connect any session problems with the code that you provided. -

Sorry, I wasn't being sarcastic. It was due to sending HTML in a textbox. doesn't like it. I usually get an error about it, but this time just error initializing session. Just strange. And has taken up my whole day. Thanks. -

yes, that's because of the @Page declaration named EnableRequestValidation (or similar; you'll see it). It's on by default. It rejects requests that contain XML in query, form, cookies - and it rejects them BEFORE you can even touch them at the aspx level (before new Page is even invoked). You can catch that in global_error, or enable for specific pages and validate well, especially in other handler on the same page where that's not needed. -

2 Respuestas

Por favor eliminar Response.End(); from the code behind and check.

Respondido 01 Feb 12, 08:02

Sorry, that code was added to simply test the page. That way I could rule out the rest of my code as being the problem. - Michael C. Gates

Prueba esto:

Response.Write("<br />" + key + " = " + (Request.Form("textArea")[key].ToString()));


Eliminar Response.End();

Respondido 01 Feb 12, 09:02

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.