Use HttpResponse.End() For A Fast Webapp?

May 30, 2010

HttpResponse.End() seems to throw an exception according to msdn.Right now i have the choice of returning a value to say end thread(it only goes 2 functions deep) or i can call end().

I know that throwing exceptions is significantly slower (read the comment for a C#/.NET test) so if i want a fast webapp should i consider not calling it when it is trivially easy to not call it?

-edit- I do have a function call in certain functions and in the constructor in classes to ensure the user is logged in.So i call HttpResponse.End() in enough places although hopefully in regular site usage it doesn't occur too often.

View 2 Replies


Similar Messages:

Why Does Custom HttpResponse Throw Exception On HttpResponse.End()

Jul 27, 2010

I'm writing some code in which I need to use my own HttpResponse object to capture the output from a method on another object that takes an HttpResponse as a parameter. The problem is, this other object (which I cannot modify) calls HttpResponse.End(), which causes an "Object reference not set to an instance of an object" exception to be thrown. What can I do about this?

Dim myStringbuilder As New StringBuilder
Dim myStringWriter As New IO.StringWriter(myStringbuilder)
Dim myResponse As New Web.HttpResponse(myStringWriter)

someObject.doStuffWithHttpResponse(myResponse) ' calls myResponse.End() and crashes

Here's some more complete information about the error, thrown from the following code in a console application:

Dim myStringbuilder As New StringBuilder
Dim myStringWriter As New IO.StringWriter(myStringbuilder)
Dim myResponse As New Web.HttpResponse(myStringWriter)
Try
myResponse.End()
Catch ex As Exception
Console.WriteLine(ex.ToString)
End Try

Here's the text of the exception:

System.NullReferenceException: Object reference not set to an instance of an object.
at System.Web.HttpResponse.End()
at ConsoleApplication1.Module1.Main() in C:Documents and Settingsjoe.userLocal SettingsApplication DataTemporary ProjectsConsoleApplication1Module1.vb:line 10

View 2 Replies

C# - Read Specific Div From HttpResponse?

Feb 22, 2011

I am sending 1 httpWebRequest and reading the response. I am getting full page in the response. I want to get 1 div which is names ad Rate from the response. So how can I match that pattern?

My code is like:

HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create("http://www.domain.com/");
HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();
Stream response = WebResp.GetResponseStream();
StreamReader data = new StreamReader(response);
string result = data.ReadToEnd();

I am getting response like:

<HTML><BODY><div id="rate">Todays rate 55 Rs.</div></BODY></HTML>

I want to read data of div rate. i.e. I should get Content "Todays rate 55 Rs." So how can I make regex for this???

View 3 Replies

Web Forms :: Can Use HttpResponse From An Ascx File

Feb 19, 2011

I am looking to render excel from an web control. I have code that works from a web page, but when I run it in an ascx.cs file it doesn't do anything.

Is there something about being in an ascx that makes a difference?

Here is my code:

Response.ClearContent();
Response.AddHeader("content-disposition", "attachment; filename=file.xls");
Response.ContentType = "application/vnd.ms-excel";
Response.BinaryWrite(result);
Response.End();
Response.Flush();

View 6 Replies

Intercept What's Being Written To HttpResponse.OutputStream

Feb 17, 2010

I am working on a tool which audits access to existing web application. Existing app does not have any hooks in place, but my plan is to inject an IHttpModule by modifying web.config and log whatever I need to log during EndRequest event.

What I'm struggling with right now is: I cannot intercept what is application writing to an output stream. I need to know what output does the application send to the client. Originally, I hoped I could run a code in BeginRequest to replace HttpContext.Response.OutputStream with a stream of my own, which would be flushed to original stream during EndRequest, but the stream only has a get accessor, so I cannot replace it.

I could of course use reflection to assign to private member of HttpContext.

View 2 Replies

C# - How To Read The HTML From An HttpResponse Object

Aug 1, 2010

I'm creating a custom module and I need to be able to read the html output that's written to the HttpResponse object. Can anyone provide direction on this?

View 2 Replies

Create Object Of HttpResponse Class?

Feb 11, 2010

how to create object of HttpResponse class

HttpResponse response=new
HttpResponse (TextWriter
tx);

how to inplement this wrong code to right one & how to implement TextWriter.

View 2 Replies

Saving HttpResponse / Request To File System

Mar 15, 2010

User fills out this large page which is dynamically created based off DB values. Those values can change. When the user fills out the page and hits submit we want to save a copy of the page as html on the server, this way if the text or wording changes, when they go back to view their posted information, it is historically accurate.

So I basically need to do this

protected void buttonSave_Click(object sender, EventArgs e)
{
//collect information into an object to save it in the db
bool result = BusinessLogic.Save(myBusinessObject);
if (result)
//!!! Here is where I need to save this page as an html file on my servers IFS!!!!
else
//whatever
Response.Redirect("~/SomeOtherPage.aspx");
}

Also I CANNOT just request the data from the url because query string parameters are a big no no in this case. The key to pull the database info up (at its highest level) is all in session so I cant just request a url and save it.

View 2 Replies

Httpresponse - Why Are .docx Files Being Corrupted When Downloading From A Webpage

Mar 19, 2010

I have this following code for bringing page attachments to the user:

[code]...

The problem is that all supported files works properly (jpg, gif, png, pdf, doc, etc), but .docx files, when downloaded, are corrupted and they need to be fixed by Office in order to be opened.

At first I didn't know if the problem was at uncompressing the zip file that contained the .docx, so instead of putting the output file only in the response, I saved it first, and the file opened successfully, so I know the problem should be at response writing.

View 3 Replies

Httpresponse - How To Handle Errors When Using C# To Create A Zipfile For Download

Oct 29, 2010

I'm working on a functionality in my asp.net web site that enables the user to download some files as a zip file. I'm using the DotNetZip library to generate the zip file.

My code looks like this:

protected void OkbtnZipExport_OnClickEvent(object sender, EventArgs e)
{
var selectedDocumentIds = GetSelectedDocIds();
string archiveName = String.Format("archive-{0}.zip", DateTime.Now.ToString("yyyy-MMM-dd-HHmmss"));
AddResponseDataForZipFile(Response, archiveName);
try
{
string errorMessage = Utils.ExportToZip(selectedDocumentIds, arkivdelSearchControl.GetbraArkivConnection(), Response.OutputStream);
if (!string.IsNullOrEmpty(errorMessage)).......

Now, if anything goes wrong, say the Utils.ExportToZip method fails, I want to present an error message to the user and not the download dialog. Do I have to remove some data from the Response object in order to cancel the download operation?

View 2 Replies

C# - Will HttpResponse - Filter Buffer The Whole Data Before Start The Sending?

Apr 6, 2010

An user posts this article about how to use HttpResponse.Filter to compress large amounts of data. But what will happen if I try to transfer a 4G file? will it load the whole file in memory in order to compress it? or otherwise it will compress it chunk by chunk?

I mean, I'm doing this right now:

public void GetFile(HttpResponse response)
{
String fileName = "example.iso";
response.ClearHeaders();
response.ClearContent();
response.ContentType = "application/octet-stream";

[Code]....

So at the same time I'm reading, I'm compressing and sending it. Then I wanna know if HttpResponse.Filter do the same thing, or otherwise it will load the whole file in memory in order to compress it. Also, I'm a little bit insecure about this... maybe is needed to load the whole file in memory to compress it... is it?

View 1 Replies

Images Not Resolving In Asp Webapp (c#)?

Mar 22, 2010

I've been working on an asp web application, which involves the user registering details of a person, including an image of the person. The file name of the details/image are stored in a SQL database with the image filename storied in an NVARCHAR column, rather than storing the actual image in the DB.I created a directory C:Images to which the image files would be stored by the application. The application works correctly in as far as it moves the images to this location, but when I open the page which would display the details/image the image never renders.

I got round this during development by having the image stored in a folder which was part of the project, but after release of the project to the server, the application refuses to allow the image to be saved in any directories within C:Inetpubwwwroot .So I need find out why the images won't render when they are stored in folders not within the project.I've checked the source of the HTML page which also points to the correct location and file name:

img id="ctl00_MainContent_CandidateImage" src="C:Imagesapplicant11.jpg" alt="Candidate Image" style="border-width:1px;border-style:solid;height:208px;width:208px;"

The code behind page renders the image in the code below:

// CandidatePhoto filename retrieved from DB.
CandidateImage.ImageUrl = "C:\Images\" + CandidatePhoto;

View 6 Replies

C# - White-labelling .NET Webapp?

Nov 26, 2010

I have an ASP.NET webapp that business customers in India wish to purchase and run within their premises (it's for industrial use). What's my best approach to do this, but not lose control of my IP? Some concerns I had:

Does ASP.NET4 code still need to get obfuscated to protect against reverse engineering, and how would this be done?Do I need to create a separate build specific to each customer that is restricted in some manner (eg. tied to physical box attributes such as CPU)?Is it possible for me to be the sole admin on the box, but give remote access to the folders that contain my CSS and HTML. That way I can maintain control over the code, but give the limited access the custom needs to customize the webapp to their site's look and feel.

View 1 Replies

Web Forms :: Accessing HttpResponse Page.Response From A Class Instead Of Cs File?

Oct 18, 2010

I have an issue with trying to create a Pdf file from my webpage. Basically, everythig involving creating the Pdf (using iTextSharp) is done, and I'm doing this as a File Stream (i.e, I'm saving the Pdf on local machine). Now what I'm trying to do is create it as a Memory Stream (i.e, open the Pdf from the browser). I was able to do this earlier when I wa still at the 1st version of the application, and all of the code behind was incluced in my .aspx.cs file. But now, I've kept the code in the .aspx.cs at a minimum and put the cude in classes and I'm creating onjects of thoses classes from the .aspx.cs

The problem is that the code from creating the Memory Stream is in a class as follows:

[Code]....

As you can imagine, the compiler cannot recognise "Response" as it's in a seperate class instead of in .aspx.cs

View 5 Replies

C# - No Trailing Slash In Hostname, HttpResponse.RemoveOutputCacheItem Doesn't Work?

Feb 19, 2011

I have an action for which the output is fairly static, until another action is used to update the datasource for the first action. I use HttpResponse.RemoveOutputCacheItem to remove that action's cached output so that it is refreshed next time the user loads it.Basically I have an action like this:

[OutputCache(Duration=86400, Location=OutputCacheLocation.Server)]
public ActionResult Index()
{
return ...
}

[code]...

View 3 Replies

Web Forms :: Schedule Hours For Using WebApp?

Jul 22, 2010

Schedule Hours for Using WebApp?

View 7 Replies

Sharing WebApp Url Inside A Network?

Oct 8, 2010

I thought I would just replace the localhost with my computer and it will work but it does not:

http://10.90.108.66/MyWebApplication/Default.aspx

How can I make it work so I can share the url?

View 1 Replies

Ship A Small Webapp With IIS Express?

Jan 28, 2011

Is there a way to ship a small webapp in MVC2 with IIS Express, so there will no need for installing it on IIS, what's the version, ohh I don't have cause I want to run this on Windows Vista Home, etc etc ...

Kind'a having a small exe and run the WebApp on the IIS Express, for those who prefer the web environment rather than a windows environment to work, and off course, been a webapp, it should be able to be access it from any computer on the ethernet.

View 1 Replies

Prelim Work On An Insurance Webapp?

Jan 28, 2011

I am doing some prelim work on an insurance webapp that will take the place of the old legacy system currently in use. Looking mainly at such things as design techniques, looks, flow, etc. Others are working on the updated db. The eventual plan is to assemble this development in sections. Sections such as policy management, claims management, risk management, and so on.

What I am posting about is to see if anyone has worked on such a development and if so would it be better to do a website or a webapp? Does anyone know of any websites that would have screenshots of the different screen sections for viewing? These will at least get the group looking and thinking of what is needed for when the real design time comes. Any open source that is available to view? Like I mentioned this is just some early prelim work being done. I've been doing some googling but not finding a whole lot.

View 1 Replies

.Net 4 WebApp Events Not Firing On Default?

May 25, 2010

I have this strange problem where if I setup IIS to point at a .net 4 webapp none of my events fireSo lets say the site in IIS is "http://www.mysite.com"...any button I click doesnt ever hit a breakpointNow if I add /default.aspx to the end...all the events fire againDefault.aspx is the top default document in IIS

View 2 Replies

Web Forms :: Trying To Create An Instance Of System.Web.HttpResponse To Send The Uers To Another Website?

Jul 11, 2010

I am trying to create an instance of System.Web.HttpResponse to send the uers to another website.I am doing some other stuff in my vb.net that does not let me use the regular Response.Redirect.when I do Dim myRsp As System.Web.HttpResponse = New System.Web.HttpResponseit complains about a textwriter.

View 4 Replies

Looking For Devexpress PivotGrid/PivotTable For Java Webapp?

Jan 26, 2011

I've just been looking around a little at the Devexpress PivotGrid/PivotTable and wow, I'm impressed (see here for an example, skip towards end to see some of the functionality).

I'm working on a java webapp in which the tabular data presented is the key part of the application, and if I could implement something such as the Devexpress control that would be amazing. Is there anything out there?? The java webapp uses the myfaces framework.

View 2 Replies

Insert Records In My Webapp Into A Simple Sql-db-table.?

Dec 28, 2010

I need to insert records in my webapp into a simple sql-db-table. The thing is, that the user chooses the position of every new record to insert. If I take an integer index, and the user want to insert an object between the 3rd and the 4th object, it is not possible, because 3.5 is no integer-value. An index of real could be the solution. Probably a litte complicated, as soon as a new object needs to be inserted between 3.45 and 3.89 (example).

If you know an easier approach for inserting records at any position by having the ability to sort by the initially choosen order (index?)

View 2 Replies

Php - Webapp Sending Email Via Gmail SMTP?

Jun 24, 2010

TL;DR - Any webapp devs out there able to squeeze performance out of using gmail as SMTP server without a 3-10 minute delay to delivery?I'm looking for some feedback from developers who are using gmail as a secure SMTP server for use with Webapps.Within the past 2 weeks, my company has switched to gmail to host email for our domains.I have a few webapps that send from our ISP server, but I'd like to refactor the code to use gmail with our domain name. I know the ISP can rig things up, but I don't want relay issues.I have gmail sending for the Webapps and it's more or less working. On ASP/IIS, I'm using SSL and on PHP Linux, I'm using TLS.It seems that TLS (port 587) works better than plain old SSL (port 465), but the overall performance difference seems minimal.What concerns me is that there is often a significant delay (10-20 minutes at times) to get email to a recipient no matter which method I use to send via gmail.While I understand this can happen in any environment, I am used to fast delivery. Use case is salespeople talking to customers and needing to get email to them very quickly using the Webapp. Before the gmail switch, usually less than a minute to deliver. Now, it is 3-4 minutes minimum.Am I crazy to try to use gmail for this purpose? There seem to be a lot of devs using it, so just wanting to know how it works out for them/you.

View 3 Replies

.NET WebApp Authentication Error -The Specified Domain Either Does Not Exist?

Nov 9, 2010

I work for a local library that just had a consulting company do a migration of their IIS installation from one server to another.It wasn't until a few days ago that my boss noticed that login.aspx seemed to have broken. I have little knowledge of ASP.NET but I just have a feeling this is something really simple. Here is the error when trying to login to the webapp:

Error authenticating. Error authenticating user. The specified domain either does not exist or could not be contacted.Active Directory was on a completely different machine and was not migrated to different hardware .The app connects to a sqlexpress server and that is running and the database is there ... Under ASP.NET Configuration Settings the sqlServerWebConnection points to the machine running the sql server. What am I missing?

EDIT: Under login.aspx.cs I have

string adPath = "LDAP://DC=COMPANY,DC=org"; //Path to your LDAP directory server ecause the webapp used to run on IIS on the DC, is that the line that somehow needs modified?

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved