Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 864569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:30:00+00:00 2026-05-15T09:30:00+00:00

I need to provide an export to excel feature for a large amount of

  • 0

I need to provide an export to excel feature for a large amount of data returned from a WCF web service.

The code to load the datalist is as below:

List<resultSet> r = myObject.ReturnResultSet(myWebRequestUrl);  //call to WCF service
myDataList.DataSource = r;
myDataList.DataBind();

I am using the Reponse object to do the job:

Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment; filename=MyExcel.xls");
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter tw = new HtmlTextWriter(sw);
myDataList.RenderControl(tw);
Response.Write(sb.ToString());
Response.End();

The problem is that WCF Service times out for large amount of data (about 5000 rows) and the result set is null. When I debug the service, I can see the window for saving/opening the excel sheet appear before the service returns the result and hence the excel sheet is always empty. Please help me figure this out.

EDITED TO ADD – WCF site’s IHttpModule used to rewriting the URL is being called twice or thrice. Could this be because of a aspnet_wp recycle? In that case I should be seeing the error on my Application Event Log, right? But I don’t. Please help me with this issue.

Here is my custom HttpModule:
public class CustomHttpModule : IHttpModule
{
public void Dispose() { }

public void Init(HttpApplication appln) 
{ 
    appln.AuthorizeRequest+= delegate 
    { 
        HttpContext tcontext= HttpContext.Current; 
        string path = tcontext.Request.AppRelativeCurrentExecutionFilePath; 

        int i = path.IndexOf('/', 2); 
        if (i > 0) 
        { 
            string svc = path.Substring(0, i) + ".svc"; 
            string fu = path.Substring(i, path.Length - i); 
            tcontext.RewritePath(svc, fu, tcontext.Request.QueryString.ToString(), false); 
        } 
    }; 
} 

}

I see that appln.AuthorizeRequest is called twice. I think this is why I am seeing the operation time out or the connection closed exception. How do I stop it from doing it twice. I only create one request.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T09:30:01+00:00Added an answer on May 15, 2026 at 9:30 am

    Tor’s response helped me a little bit. I had to set the MaxItemsInObjectGraph to a higher value for this exception to go away. However, I had trouble setting this value because I didn’t how to set it and where to set it.

    This article helped me understand more about WCF Rest service and throttling. What actually worked for me was setting the ServiceBehavior attribute for my service class.

    [ServiceBehavior(MaxItemsInObjectGraph=2147483646)]
    public abstract class MyService: IMyService
    

    {
    blah…
    }

    If you aren’t concerned about having to change the max limit over and over, you could be happy with specifying it in code and have the fun in seeing it all working.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a wcf web service and I need to provide the client with
I need to provide our web developers an easy and quick way to test
I need to provide some passwords, API keys and similar sensitive data in my
I have a few large forms that I need to provide visual cues about
Frequently I need to collect structured information from colleagues and arrange into excel, instead
I need to export some project from a repo at my work, im using
I need to provide webpage (made for desktop browsers) to be usable on mobile
On the form I need to provide the validation where the validation depends on
To create facebook android native app we need to provide our Android application signature
I'm currently writing an app in Python and need to provide localization for it.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.