您好。我需要使用http标头StatusCode作为响应。 例如我的页面有名称check.aspx我得到这样的请求 check.aspx?idcustomer = 1395 我使用这个idcustomer param来检查我的数据库中是否存在此客户 以及是否存在显示页面(http StatusCode == 200),但如果客户编号为 1395不存在我需要make 404 http错误(页面不存在) 我想要做类似的事情 protected void Page_Load(object sender,EventArgs e) { Response.StatusCode = 404; Response.End(); } 但它不起作用。你可以帮助我吗?
解决方案不确定为什么你试图以这种方式使用Response.StatusCode。 你可以做的是在你的SQL中如果没有找到用户返回零然后 检查大于零的值并执行你想要的任何动作 返回价值。 问候, Brian K. Williams " SushiSean" < su ******* @ discuss.microsoft写信息 新闻:B8 ********************* ************* @ microsof t ... 你好。我需要使用http标头StatusCode作为响应。 例如我的页面有名称check.aspx我得到这样的请求 check.aspx?idcustomer = 1395 我使用这个idcustomer param检查这个客户是否存在于我的数据库中 并且如果存在显示页面(http StatusCode == 200),但是如果客户有 数字 1395不存在我需要make 404 http错误(页面不存在) 我想做一些像 protected void Page_Load(object sender,EventArgs e) { Response.StatusCode = 404; Response.End (); } 但它不起作用。你能帮助我吗?
忘了sql。这只是一个例子。问题是如何从现有页面发送http 404 响应? Brian Williams写道: 不确定为什么你试图以这种方式使用Response.StatusCode。 你可以做的是你的SQL如果用户未找到返回零然后 检查大于零的值并执行您希望的任何操作 返回值。
" SushiSean" < su ******* @ discuss.microsoft写信息 news:99 ********************* ************* @ microsof t ...
>不知道为什么你试图以这种方式使用Response.StatusCode。如果没有找到用户,你可以做的就是在你的SQL中返回零然后检查值是否大于零,并执行你想要的任何动作返回的值。
忘掉sql。这只是一个例子。问题是如何从现有页面发送http 404 回复?
Response.StatusCode = 404; Response.SuppressContent = true; HttpContext.Current.ApplicationInstance。 CompleteRe quest(); - Mark Rae ASP.NET MVP www.markrae
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?idcustomer=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(object sender, EventArgs e) { Response.StatusCode = 404; Response.End(); } but it doesn''t work. Can you somebody help me with it?
解决方案 Not sure why you are attempting to use Response.StatusCode 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*******@discussions.microsoftwrote in message news:B8**********************************@microsof t... 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?idcustomer=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(object sender, EventArgs e) { Response.StatusCode = 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.StatusCode 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*******@discussions.microsoftwrote in message news:99**********************************@microsof t... >Not sure why you are attempting to use Response.StatusCode in thismanner.What you could do is in you SQL if the user was not found return zerothencheck for values greater then zero and perform whatever action you wishfromthe returned value.
Forget about sql. It is just example. The question is how I can send http 404 response from exist page?
Response.StatusCode = 404; Response.SuppressContent = true; HttpContext.Current.ApplicationInstance.CompleteRe quest(); -- Mark Rae ASP.NET MVP www.markrae
更多推荐
Response.StatusCode问题
发布评论