我有一个web服务,我打电话通过ajax,要求用户登录。在每个方法我想检查用户是否登录并发送403代码,如果他们不是,但是当我打电话Response.End()
我得到错误“线程被中止”。我应该怎么称呼呢?Asp.Net:Web服务抛出“线程被中止”
[WebMethod(true)]
public string MyMethod()
{
if(!userIsLoggedIn)
{
HttpContext.Current.Response.StatusCode = 403;
HttpContext.Current.Response.End();
}
/* Do stuff that should not execute unless the user is logged in... */
...
}
如果我在非空类型上返回null,我会抛出一个错误吗? – 2010-04-12 12:53:08
@Master - 它不应该让你编译,但你可以抛出'default(typeHere)'来保证安全。 – 2010-04-12 12:55:48