Hello. I need use http header StatusCode as response.
For example my page have name check.aspx and I get request like this
check.aspx?idcu stomer=1395
I use this idcustomer param to check if this customer exist in my database
and if exist show page (http StatusCode == 200), but if customer with number
1395 not exist I need make 404 http error (page not exist)
I am tring to do something like
protected void Page_Load(objec t sender, EventArgs e)
{
Response.Status Code = 404;
Response.End();
}
but it doesn't work. Can you somebody help me with it? 10 14229
Not sure why you are attempting to use Response.Status Code in this manner.
What you could do is in you SQL if the user was not found return zero then
check for values greater then zero and perform whatever action you wish from
the returned value.
Regards,
Brian K. Williams
"SushiSean" <Su*******@disc ussions.microso ft.comwrote in message
news:B8******** *************** ***********@mic rosoft.com...
Hello. I need use http header StatusCode as response.
For example my page have name check.aspx and I get request like this
check.aspx?idcu stomer=1395
I use this idcustomer param to check if this customer exist in my database
and if exist show page (http StatusCode == 200), but if customer with
number
1395 not exist I need make 404 http error (page not exist)
I am tring to do something like
protected void Page_Load(objec t sender, EventArgs e)
{
Response.Status Code = 404;
Response.End();
}
but it doesn't work. Can you somebody help me with it?
Forget about sql. It is just example. The question is how I can send http 404
response from exist page?
"Brian Williams" wrote:
Not sure why you are attempting to use Response.Status Code in this manner.
What you could do is in you SQL if the user was not found return zero then
check for values greater then zero and perform whatever action you wish from
the returned value.
"SushiSean" <Su*******@disc ussions.microso ft.comwrote in message
news:99******** *************** ***********@mic rosoft.com...
>Not sure why you are attempting to use Response.Status Code in this manner. What you could do is in you SQL if the user was not found return zero then check for values greater then zero and perform whatever action you wish from the returned value.
Forget about sql. It is just example. The question is how I can send http
404
response from exist page?
Response.Status Code = 404;
Response.Suppre ssContent = true;
HttpContext.Cur rent.Applicatio nInstance.Compl eteRequest();
--
Mark Rae
ASP.NET MVP http://www.markrae.net
Thank you, Mark.
But when I use this code and open this page in browser I see just empty page.
If http responce 404 browser should show - page not found, isn't it?
protected void Page_Load(objec t sender, EventArgs e)
{
Response.Status Code = 404;
Response.Suppre ssContent = true;
HttpContext.Cur rent.Applicatio nInstance.Compl eteRequest();
}
"Mark Rae [MVP]" wrote:
Response.Status Code = 404;
Response.Suppre ssContent = true;
HttpContext.Cur rent.Applicatio nInstance.Compl eteRequest();
I tried this and it works, no problem. At least in my case on my machine
and environment.
"SushiSean" <Su*******@disc ussions.microso ft.comwrote in message
news:9B******** *************** ***********@mic rosoft.com...
Thank you, Mark.
But when I use this code and open this page in browser I see just empty
page.
If http responce 404 browser should show - page not found, isn't it?
protected void Page_Load(objec t sender, EventArgs e)
{
Response.Status Code = 404;
Response.Suppre ssContent = true;
HttpContext.Cur rent.Applicatio nInstance.Compl eteRequest();
}
"Mark Rae [MVP]" wrote:
>Response.Statu sCode = 404; Response.Suppr essContent = true; HttpContext.Cu rrent.Applicati onInstance.Comp leteRequest();
"SushiSean" <Su*******@disc ussions.microso ft.comwrote in message
news:9B******** *************** ***********@mic rosoft.com...
Thank you, Mark.
But when I use this code and open this page in browser I see just empty
page.
If http response 404 browser should show - page not found, isn't it?
Hmm - it works for me...
What version of IIS are you using...?
--
Mark Rae
ASP.NET MVP http://www.markrae.net
Visual Studio 2005
"Mark Rae [MVP]" wrote:
"SushiSean" <Su*******@disc ussions.microso ft.comwrote in message
news:9B******** *************** ***********@mic rosoft.com...
Thank you, Mark.
But when I use this code and open this page in browser I see just empty
page.
If http response 404 browser should show - page not found, isn't it?
Hmm - it works for me...
What version of IIS are you using...?
--
Mark Rae
ASP.NET MVP http://www.markrae.net
"SushiSean" <Su*******@disc ussions.microso ft.comwrote in message
news:6E******** *************** ***********@mic rosoft.com...
>What version of IIS are you using...?
Visual Studio 2005
Once again, what version of IIS are you using...?
--
Mark Rae
ASP.NET MVP http://www.markrae.net
I use VS2005 for run this page and also put into IIS6.0 and see the same
result.
Just empty page, but without 404 error.
"Mark Rae [MVP]" wrote:
"SushiSean" <Su*******@disc ussions.microso ft.comwrote in message
news:6E******** *************** ***********@mic rosoft.com...
What version of IIS are you using...?
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Chris Fink |
last post by:
How do I retrieve the HTTP Status code (ie 202, 404, etc) below? I am
currently receiving the response text but unable to access the response
status code.
string strNewValue;
string strResponse;
// Create the request obj
|
by: Shane |
last post by:
I want the function in Code Snippet #1 below to return a
string of "200" by making a web request for
the vbprogram.aspx that contains the PageLoad function in
Code Snippet #2 below. Instead, I am getting a StatusCode
of "OK" instead of 200. What should I change here? Thanks
in advance for any help anyone may be able to give.
Code Snippet #1 (The function that does the web request.)
(from a C# program I wrote.)
|
by: Shane |
last post by:
Can someone tell me what the Response.StatusCode = "200"
is doing below? I have another program that sends a
stream of string data to the program below by using an
HttpWebRequest. I want to use the HttpWebResponse or
HttpResponse to get the status code back but it doesn't
seem to work. Is the Response.StatusCode assignment below
only visiable to the web application below or is this the
response that is sent back to any programs that...
|
by: Adrian Inman |
last post by:
I have some image resizing code that resizes images and composites them with
watermarks on the fly. I have integrated HTTP eTag aware caching with the
code, however, the Response.StatusCode which I set to 304 when necessary
always shows up in the server log as a 200 even when the 304 is issued.
The browser doesn't error and behaves as expected, but I want to be able to
log the 304s as 304s, not 200s with a VERY small contentlength.
...
|
by: Martin Robins |
last post by:
I have an application which uses Windows Authentication to identify users
and ensure that they are on a domain. Once access is granted at this level,
I then check their login name against a database of validated users to
determine whether the particular user can actually use the system.
If a user is not in the database, I want to respond with the same error page
as would be seen if they failed the windows authentication; the 403...
| |
by: Hexman |
last post by:
Code below ----
I've asked a similar question on this forum earlier. This is a slightly different situation.
Previous Question ----
I'm trying to save some specific web pages to disk as text files. I searched the Internet and found a basic example which I changed to fit my needs.
I tested it out first on a single URL and it worked fine. Now when I incorporate an array of URL's, it fails to work. The first "responseFromServer"...
|
by: Flip Rayner |
last post by:
I am writing an HTTPHandler that is basically a transparent proxy / URL
Mapper.
I have a line in my code to return a 503:
context.context.Response.StatusCode =
(int)HttpStatusCode.ServiceUnavailable;
I am lead to believe that there is the ability to specify the
"retry-after" parameter in the header, but I am unsure how to do it in
..Net2
|
by: pbd22 |
last post by:
Hi.
I feel like i should know this but i dont.
How do I get the server to send a specific HTTP response to the
browser?
I want to tell the browser that there is no content coming back from
ther server and I want to do it in the HTTP Headers. The status code
is "204" for no content.
|
by: Alexander Smirnov |
last post by:
I'm developing asp.net 2 web application and need to make a custom
http handler which sometime must send response with "204 No Content"
code.
I set HttpResponse.Status="204 No Content"; But asp automatically adds
headers such as "Content-Length: 0".
This causes an error on the client. HttpResponse.ClearHeaders()
doesn't help. How to make asp not to add headers (especially Content-
Length)?
Thanks in advance.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |