473,385 Members | 1,587 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

HttpResponse not working

Hi,

Can anyone tell me why the following code produces the error

"An object reference is required for the nonstatic field, method, or
property 'System.Web.HttpResponse.Redirect(string)'"


Nov 16 '05 #1
2 6917

"Kavvy" <ka*@kav.kav> wrote in message
news:gc****************@text.news.blueyonder.co.uk ...
Hi,

Can anyone tell me why the following code produces the error

"An object reference is required for the nonstatic field, method, or
property 'System.Web.HttpResponse.Redirect(string)'"


Oops,

here is the code

private void errorScreen(string errorString)
{
HttpContext.Current.Session["error"] = errorString;
HttpResponse.Redirect("Errors.aspx"); // << produces error
}
Nov 16 '05 #2
Kavvy,

The reason for this is that the Redirect method is an instance method,
not a static method. You have to get an instance of the HttpResponse
method, like this:

private void errorScreen(string errorString)
{
HttpContext.Current.Session["error"] = errorString;
HttpContext.Current.Reponse.Redirect("Errors.aspx" ); // << produces
error
}

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Kavvy" <ka*@kav.kav> wrote in message
news:md******************@text.news.blueyonder.co. uk...

"Kavvy" <ka*@kav.kav> wrote in message
news:gc****************@text.news.blueyonder.co.uk ...
Hi,

Can anyone tell me why the following code produces the error

"An object reference is required for the nonstatic field, method, or
property 'System.Web.HttpResponse.Redirect(string)'"


Oops,

here is the code

private void errorScreen(string errorString)
{
HttpContext.Current.Session["error"] = errorString;
HttpResponse.Redirect("Errors.aspx"); // << produces error
}

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Adrian Albisser | last post by:
Hey to everybody, im just beginning to program in python. So i was trying some function but always when i try the range function i get a error message. for number in range(1,100): print number...
0
by: Matthew Trunnell | last post by:
Hi everyone, I'm implementing the HTTP 206 Partial Content spec. This requires an additional header of the form: "Content-Range: xxx-yyy/zzz" See http://www.w3.org/Protocols/rfc2616/rfc2616-...
1
by: James Dixon | last post by:
I am hitting a j2ee website that is using cookies to maintain session state. In the headers, it has the syntax Set-Cookie:JSESSIONID=XXXXXXXXXXX When I inspect the HTTPResponse.Cookies collection,...
1
by: Chris Simmons | last post by:
Hello: I am trying to better understand the HttpResponse.Filter property and, although I think I "get it," I am wondering what is going on behind the scenes. I was initially stumped with the...
4
by: Paul | last post by:
I have developed an ASP.NET web page with a VB.net for the code behind. I would like to redirect the output of the web page so I can send it as an Email. Or Redirect the HTTPResponse stream on...
5
by: Daniel Corbett | last post by:
I am trying to save a file dynamically created in a webpage. I get the following headers, but cannot figure out how to save the attachment. I am basically trying to replicate what internet...
2
by: Vadim | last post by:
Hi, I will have to send a file to a user's browser to be opened in a Save, Open manner, I am using HttpResponse.WriteFile for this, the info to be sent will have to be first accumulated in a...
4
by: =?Utf-8?B?Um9iaW4=?= | last post by:
I am looking for the most correct method of streaming a byte array to a web browser as a pdf. Anyway, I see a lot of methods for HttpResponse and I don't know how to properly use them. Here is my...
2
by: somoza.albert | last post by:
Hello, I've been told that I can make my Web Pages render quicker if I set the BufferOutput property of the HttpResponse Class to false. I have a "test" Web App that works, but it doesn't seem...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.