ssrs reportviewer loading to infinity without error message - asp.net

when i run a report with parameter in my asp.net application i see loading div to infinity
without any indication of an error (so i dont know how to search about this issue in google)
note1:
i can run the same report directly from report server
note2:
if i removed the parameter it run normally from asp.net page as well as from report server
protected void Page_Load(object sender, EventArgs e)
{
oID = (Int64)Session["OID"];
ViewReport();
}
public void ViewReport()
{
string reportServerUrl = ConfigurationManager.AppSettings.Get("ReportServerPath");
ReportViewer.ServerReport.ReportServerUrl = new System.Uri(reportServerUrl);
ReportViewer.ServerReport.ReportPath = #"/StoReports/MyReport";
ReportViewer.ServerReport.SetParameters(new ReportParameter("OID", oID.ToString()));
ReportViewer.ServerReport.Refresh();
}
in a function called Sys$WebForms$PageRequestManager$_endPostBack(error, executor, data)
tools sql server Denali , visual studio 2010

this article explains the issue in details
1-Browser makes a GET request to the ASPX page to get the page content
and a loading indicator for the report.
2-Browser makes a POST request
to the ASPX page to get the HTML for the report (this content is in an
UpdatePanel).
3-Browser makes GET requests to the HTTP handler to get
all the images in the report In step 2 the request to get the report
content runs the ASP.Net page, including any code you have placed in
the page.
Why does this matter? code was added to the load event of the page
that altered the state of the report viewer. The most common example
I’ve seen is user code calling SetParameters in the load event, though
there are several methods and properties that will trigger this.
Changing the parameter values tells the ReportViewer that it needs to
restart report processing. Effectively, it tells the viewer to return
to step 1 – put the loading indicator in the browser and restart
report processing. If you do this during every postback, the viewer
never successfully completes step 2. It just goes into an infinite
loop.
Calling methods like SetParameters isn’t cheap. Each call triggers a
round trip to the report server. So it’s a call you want to minimize
anyway. By only calling SetParameters during the initial GET request
or only when parameter values have actually changed, you can improve
the performance of your application and break the loop. A simple
check of IsPostBack before calling SetParameters is usually
sufficient.

Related

Passing C# custom objects in Session between asp.net web pages

I have a frustrating issue when trying to pass a custom object from 1 page of a web site to another. When I try to use the object from session on the page 2 it is null. I believe that my syntax is correct as when I take the code out of my larger solution and run it on it's own it works fine.
I am wondering if there are any settings in visual studio, aspx files, project properties that may be set on my project that may be causing this session object not to work?
Simplied syntax that I am using is;
on page1
Person p = new Person;
p.name = "john";
p.secondName = "doe";
Session["person"] = p.
Response.Redirect("Page2.aspx")
Page 2 on page load method
Person p = (person)Session["person"]
textbox1.Text = p.name;
textbox2.Text = p.Secondname;
As I said this code works fine on it's own but not as part of my larger works project. Any ideas on why this may not be working would be greatly appreciated
There are three possible options.
First one is that inside your larger project session state is disabled. Please visit Turn Off ASP Session State in Active Server Pages and IIS for more details.
Second option would be that exception occurs somewhere inside your application (separate thread) resulting in application restart and session state loose. You can check this by hooking to Application error inside Global.asax like this:
void Application_Error(object sender, EventArgs e)
{
Exception ex = Server.GetLastError();
}
The last option would be that session["person"] value is changed in other module or page.
Try code with,
Response.Redirect("Page2.aspx", false);
See as per your code if there is database connected then i suggest you to do whatever you want to on page1 and save it to db in single or multiple tables, depending upon the requirements. Now paas the id to page2 as querystring. Format looks like
Response.Redirect("~/page2.aspx?id=67");
where is the dynamic unique id from database. Now on page 2.aspx query on the id you have passed.

Request param missing on POST

I am re-writing an ASP.NET application and noticed a difference in behaviour ...
In my Page_Load event I have some code such as:
string id = Request["id"]
which gets the id param from the URL. On page load (ie a HTTP GET), this works as expected in both versions. I also have a button onclick event handler. Clearly, this performs a POST to the server, and also invokes the Page_Load handler. The difference is, that in the original version of the app, the id is successfully loaded from the request. In the new version of the app, id comes back as null. I have discovered that I need to use Request.Params["id"] instead, but am totally puzzled as to why Request["id"] works for POST requests in one app but not the other.
The only difference between the apps is that the first was created as File -> New Website and the second File -> New Web Application. I think this is what is causing the difference in behaviour, but am wondering why this subtle difference, and also if there is anything else I should be aware of between the 2.
Any advice greatly appreciated.
As you have mentioned, you have the id parameter coming through twice. This will be because you have one in the query string parameters and one in the form parameters. I'm not sure why this would be occurring in one web app and not the other, but you can make changes to your code to account for it in a more correct way.
If you view the source of the HTML in your browser, you will see that the action value for the form will be current pages URL, including the query string. This is why the first id is being sent through. Evidently, the second id is coming through via the form itself:
HTML Source of basic web form
<form method="post" action="Default.aspx?id=3" id="ctl01">
<input type="text" name="id">
</div>
There are a couple of things you can do here:
first off, I wouldn't use Request.Params["id"] for this, as it combines the query string, form, cookies and server variables into one collection. You should use Request.Querystring and Request.Form properties, based on what you require and when
In your Page_Load handler, use the Page.IsPostBack property to determine whether the page is loading for a GET or POST and use the Request properties described above.
Example of Page.IsPostBack usage:
protected void Page_Load(object sender, EventArgs e)
{
string id = string.Empty;
if (Page.IsPostBack)
{
id = Request.Form["id"];
}
else
{
id = Request.QueryString["id"];
}
}
I always use web applications project but the difference is compilation. Website has a dynamic compilation, which means that the first request will be slower and web app has pre-compiled release dlls.
Check this for pro's and con's : http://maordavid.blogspot.ca/2007/06/aspnet-20-web-site-vs-web-application.html

Sharing session via web request

I have spend a lot of time on this problem without any change :
I have got 2 simples apsx page, in the first page the
Page_Load event put data in the session ;
later the on_click event of a button fire an HttpWebRequest to the second
page
with the idea to retrieve on the page_load of the second page the data in
the session.
to sum up : 1st page put data in session, make the httpWebRequest to the 2nd
page
2nd page : try to get the stored data in the session.
This is the different attempt of code i 've tested to perform this action,
the result was always the same. When i try to add sessionId Information (via
a cookieContainer or directly in the Header request) i get a timeout exception
System.Net.HttpWebRequest.GetResponse() and when i do the HttpWebrequest
without the session_id information i get the response immediatly but without
the session info :-)
It's not clear what you're trying to do, but have you considered using Server.Execute instead?
http://www.west-wind.com/weblog/posts/2004/Jun/08/Capturing-Output-from-ASPNet-Pages

ASP.NET Caching - Programatically Invalidating Server Cache...confusion on example

I'm reading how to programmatically invalidate cached pages on the server in ASP.NET, and the book ("MCTS Self-Paced Traing Kit (Exam 70-515)") says:
To directly control whether a cached
version of a page is used or whether
the page is dynamically generated,
response to the ValidateCacheOutput
event and set a valid value for the
HttpValidationStatus attribute.
The code segments look like the following:
public static void ValidateCacheOutput(HttpContext context, Object data,
ref HttpValidationStatus status)
{
if (context.Request.QueryString["Status"] != null)
{
string pageStatus = context.Request.QueryString["Status"];
if (pageStatus == "invalid")
status = HttpValidationStatus.Invalid;
else if (pageStatus == "ignore")
status = HttpValidationStatus.IgnoreThisRequest;
else
status = HttpValidationStatus.Valid;
}
else
status = HttpValidationStatus.Valid;
}
protected void Page_Load(object sender, EventArgs e)
{
Response.Cache.AddValidationCallback(
new HttpCacheValidateHandler(ValidateCacheOutput),
null);
}
Could someone please explain to me what this code is doing? Also, the main question I have is that I thought Cached pages were simply returned from the server, but the code below indicates that the page life-cycle is being invoked (Page_Load event); I'm confused because the page life-cycle isn't invoked if a cached page is returned, so how would the code in the Page_Load event even fire?
Note: Here's the same example that the book has
I also came across this question. It is too bad that almost every blog post and article I find about this subject dutifully replicates the MSDN example without really explaining how it works.
I don't have a definite answer but I think this works because the page life cycle is invoked at least once. Namely when the page is requested for the first time and thus isn't cached yet.
During that first request the Page_Load is called and the HttpCacheValidateHandler is registered with the Cache object. During all subsequent request for that page, the Cache object is able to call your ValidateCacheOutput() method. And because this method is static the page life-cycle doesn't have to be invoked.
I hope that someone who knows more about this can comment on it but in my opinion this also implies the following:
In the given example the HttpCacheValidateHandler doesn't need to be a static method of the page because it doesn't use any properties of the Page object. It can be a static method on any other object you like.
The ValidateCacheOutput() method will probably be called for every page request, not just for the page which is (ab)used to call Response.Cache.AddValidationCallback(). Maybe i'm missing something obvious but I don't see how the Cache "knows" which HttpCacheValidateHandler belongs to which page.
You are right in that typically cached pages are just returned frm the server but this changes when you use AddValidationCallback. In this case, ASP.NET will call this method to determine whether to returned a cached copy or not. This method should therefore be very light or you will negate the effect of caching.
The code you have listed just checks the querystring for a Status variable and uses the value of this to determine whether to either (1) pull the page from the cache, (2) clear the cached page, re-render it and cache it or (3) just ignore the cache and re-render the page.
See http://msdn.microsoft.com/en-us/library/system.web.httpvalidationstatus.aspx for the status options.

Asp.Net CreateChildControls() - Re create controls with Postback data - Event

I have a WebPart custom control (Composite) in .Net, which gets created on page load to show a Chart using 'Dundas Charting Controls' (this is created by a user control inside the page). I get the properties for this control from the database.
I have another control, which is a Filter (outside webpart) and based on data of this filter control which the user selects and which I would get on postback after click of button, I have to show the filtered chart results. The problem is CreateChildControls() gets called before the postback data is available (which would be available only after the Page_Load event fires).
I'm unable to get this data in time to pass on the parameters for filtering the Chart Results.
The implementation os like this ...
Webparts
Page > User Control > Webparts > Composite Control/Chart
Filter
Page > User Control > Composite Control [I get this data on Postback]
It sounds like you are running into an event ordering issue. I always try to make my controles relatively dump - so they don't really know how they are being used.
Consider creating a method in your chart control to force an update of its data:
public void UpdateChart(-- arguments as needed --)
then create an event in your composit control (that has your filters) like
public event Eventhandler FiltersChanged;
Assign this to an event hander on parent page:
filterControl.FiltersChanged += new EventHandler(Filter_OnChange)
Then create an event handler that tells your chart control about the change
Filter_OnChange(Object sender, EventArgs e)
{
// get whatever data you need from your filter control
// tell the chart about the new data and have it reload/redraw
myChart.UpdateData( - filter options here -}
}
In doing so, you let the page direct the order of operations and do not rely on the order in which the child controls Load methods are called.
James - Thanks for your answer, but this does not seem to work in my scenario or rather I couldn't make it work, when I tried it. The controls seems to be doing too much and is getting data from every where, it has its own constructor implementation, Load() override etc so a single UpdateChart() function may not have done the trick in this case.
This is what I did, finally.
I fire an Ajax request with Filter Data and set the value in a Session Variable before page does a Postback, this way I get the data at all places/events, and pass on the same as parameter where required. I know it may seem weird way to implement this, but it saved additional Database calls (which in this case are many to create the controls again) even though it comes at the cost of an additional Server HTTP ajax request.
Let me know this implementation can have any negative impact.

Resources