ASP.NET 4.5 ViewState not available - c#

I already searched on many Websites but I found no solution :-(
I want to use the ViewState after the Postback (after clicking on a Image link).
my PageLoad:
protected void Page_Load(object sender, EventArgs e)
{
...
if (!IsPostBack && !IsCallback)
{
pivotPlan.DataSource = Keys.ToList();
ViewState["pivotPlan"] = pivotPlan.DataSource;
}
else
{
pivotPlan.DataSource = ViewState["pivotPlan"];
}
}
The strange Thing is that the ViewState is null when I step through the code and the Debugger reaches the masterpage. I enabled the ViewState in the masterpage, but when I click on the imagebutton I will get this error:
Server Error in '/' Application.
The state information is invalid for this page and might be corrupted.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: The state information is
invalid for this page and might be corrupted.
Source Error:
[No relevant source lines]
Source File: c:\Users\neunin\AppData\Local\Temp\Temporary ASP.NET
Files\root\7b4d9801\69af7fa1\App_Web_2nxwrvxv.1.cs Line: 0
I really don't have a clue what the Problem is :(
Maybe anybody can help me?
Thank you very much in advance! :-)
Regards,
Nina

That source file looks suspicious to me. If you created a new ASP.NET website, tried adding some basic info to ViewState, and then retrieving it, does it work? I'm wondering if you should delete all ASP.NET temp files and try compiling\running the app again, check out this answer: ASP.NET Temporary files cleanup
Hope this helps, and welcome to SO :)

Related

Application crashes on element reader (pdftron)

I have an issue with pdftron, where opening a certain file, will cause our application to crash with following error:
An unhandled exception of type 'pdftron.Common.PDFNetException' occurred in PDFNet.dll
Additional information: Exception:
Message: Missing resource
Conditional expression: res
Filename : ContentResources.hpp
Function : trn::PDF::ContentResources::GetResource
Linenumber : 26
In our code: it's in the following line that the error occurs:
while ((element = elReader.Next()) != null)
When doing try/catch, we see that the only thing missing from the page is the text that's written diagonally on that page. Does this have anything to do with a missing font maybe ? Don't mind the cursor in the picture, it doesn't know where to go with the text missing.
I can send the pdf file on request.
PDF File
If you are not on the latest version of PDFNet, 6.7.1, then I would first try against that, as the issue might have been resolved already.
Otherwise, since the issue is document specific, you would need to provide that, by either sharing here, or sending to pdftron support.

GraphDiff Update Graph returning f:\Work\GitHub\GraphDiff\GraphDiff\GraphDiff\DbContextExtensions.cs

Hi I don't have much experience in development.This is my first project as i am fresher.I am trying to update entity in Sql Databse using GraphDiff.But it is returning me "You need to find DbContextExtensions.cs to view the source for the current call stack frame" while debugging.
Anyone please help me.Below is the code i am using for this.
using (var context = DataContext)
{
context.UpdateGraph(memberEntity);
context.SaveChanges();
}
This is the message of what Visual Studio debugger try to show you where the bug was in the specified source code. What you should be aware of is the detail information regarding to the exception you encountered or the debugger captured but not the source code...

ASP.NET getting the URL of a redirect after interacting with a login prompt

I'm trying to scrape the URL from an IE browser control after completing Facebook login. The problem arises when I try to detect the redirect after the login. I'm using the Response.Redirect(Url,false) function, but that simply allows me to interact with the page before it loads but not afterward.
How do I detect the redirect after the page has loaded (triggered at end of log in process) when no response object is available in the Page_Unload function? I'm stuck.
The lifecycle doc doesn't mention any state after unload which is exactly when I have to scrape the URL. I've tried using IsPostBack however the code never reaches this point until after I've closed the window. Any help is greatly appreciated.
System.IO.StreamWriter file = new System.IO.StreamWriter(#"C:\Users\user_name\LogUnLoad.txt");
System.IO.StreamWriter errorfile = new System.IO.StreamWriter(#"C:\Users\user_name\LogUnLoadError.txt");
try
{
base.OnUnload(e);
if (Page.IsPostBack)
{
file.Write("\r\n This branch does not get executed. Neither does this");
}
}
catch( Exception ex)
{
errorfile.Write("Page_Unload \r\n\t Error Message \r\n\t\t:"+ex.Message +"\r\n\t Stack Trace: \r\n\t"+ex.StackTrace);
errorfile.Close();
file.Close();
}
source for page lifcycle: http://msdn.microsoft.com/en-us/library/ms178472(v=vs.85).aspx
Update: I'm the Global.asax file suggested here .
I thought asking for the previous URL before close would be the solution but no dice.
Just in case someone likes to skip over the comments I'll put this here.
If you check the HttpRequest.UrlReferrer you can get the URL of the previous page. This can be used to check for redirects.

Weird Error screen in ASP.net Application

I am working on some ASP.NET Application. In case of some breakdown or error, I am getting some weird error screen. The error page shows something like:
��`I�%&/m�{J�J��t��`$ؐ#�������iG#)�*��eVe]f#�흼��{����{����;�N'���?
\fdl��J�ɞ!���?~|?"��Ey�')=��y6�����h��贮
�:�V�˼n��E:��,m�Wy�����<�ӶJ�e;~|W^�`4�u�A:�f��/>
and so on....
The application is currently in test phase so, I have left the error screen visible from web.config. Anyone who have faced the same issue, and got the problem and solution for it?
Check out whether the ASP.NET application you are working on utilizes some form of automatic GZip compression, your error page is very reminiscent of what Rick Strahl describes here: http://www.west-wind.com/weblog/posts/2011/May/02/ASPNET-GZip-Encoding-Caveats. There is also a solution in that blog post.
Thanks to Rick Strahl for the solution, and #Andrew Sklyarevsky for referring :D
Reference and Complete Description: http://www.west-wind.com/weblog/posts/2011/May/02/ASPNET-GZip-Encoding-Caveats
I solved the issue, and thus the solution, is adding following codes to Global.asax:
protected void Application_Error(object sender, EventArgs e)
{
// Remove any special filtering especially GZip filtering
Response.Filter = null;
…
}
Or even better
protected void Application_PreSendRequestHeaders()
{
// ensure that if GZip/Deflate Encoding is applied that headers are set
// also works when error occurs if filters are still active
HttpResponse response = HttpContext.Current.Response;
if (response.Filter is GZipStream && response.Headers["Content-encoding"] != "gzip")
response.AppendHeader("Content-encoding", "gzip");
else if (response.Filter is DeflateStream && response.Headers["Content-encoding"] != "deflate")
response.AppendHeader("Content-encoding", "deflate");
}

session value lost in asp.net in c#

hai..
Am doing wepsite for show images from local drive using asp.net.am using session object for Transfer image path from first page to second page
its running nice in vs 2003 .but i converted this website to vs 2005.but session value does't pass to next page.i got null value in session object.
am using inproc session mode
kindly help me
thanks
Your application will probably encounter an error and therefore the session will end. Afterwards a new Session is started. Accessing that value in the new value will return null.
Steps to find your error:
Create the global.asax in your Rootdirectory. Set Breakpoints for Session_OnStart, Session_OnEnd and Application_OnError and try to find where the error lies.
How you are storing the path of images.
See i am doing like this and everything goes file for me.
Session["Path"] = #"D:\Images\PNEUMATIX_MR_CardiovascularHeart Cardiac Function_6\img.jpeg";
on another page i am taking like this.
Label1.Text = Session["Path"].ToString();
And i am using sessionState mode="inProc".
My be you have some problem with path.
http://markmail.org/message/emd3swpsembfplis#query:+page:1+mid:dfdchaihfj7c46j7+state:results
Thanks god this post save my life! IE bugs with _ in the domain name .. they flush all session variable

Categories