Throw error of 401 Unauthorized so Web.config shows appropriate page

I'm making an ajax call and if the user is not an admin, i want to throw an error of type 401 - unauthorized and then let the web.config redirect the user to my access denied page: <customErrors mode="On"> <error statusCode="500" redirect="~/InternalError.html"/> <error statusCode="401" redirect="~/AccessDenied.aspx"/> </customErrors> As you can see, i have a

抛出401未经授权的错误,所以Web.config显示适当的页面

我正在做一个Ajax调用,如果用户不是管理员,我想抛出401类型的错误 - 未经授权,然后让web.config将用户重定向到我的访问被拒绝页面: <customErrors mode="On"> <error statusCode="500" redirect="~/InternalError.html"/> <error statusCode="401" redirect="~/AccessDenied.aspx"/> </customErrors> 正如你所看到的,我有一个500型内部服务器错误来处理其他错误。 但是,当我运行这个代

Unauthorized, Valid account

This is a bit complicated I'm running a .NET 4.0 site on a IIS 7.5, using Windows Authentication and running the site in custom application pool with Identity set to a Domain Admin account(need to run scripts with admin rights). My webconfig is as follows: <authentication mode="Windows"/> <authorization> <deny users="?"/> </authorization> </system.web> W

未经授权的有效帐户

这有点复杂 我正在IIS 7.5上运行.NET 4.0站点,使用Windows身份验证并在身份设置为域管理员帐户(需要使用管理员权限运行脚本)的自定义应用程序池中运行站点。 我的webconfig如下所示: <authentication mode="Windows"/> <authorization> <deny users="?"/> </authorization> </system.web> 每当我登录到网站,使用IE8(它应该自动验证我)它要求我的凭据,并提供一些通用的域用户凭据

Throwing an HttpException always sends back HTTP 500 error?

I'm trying to throw an HTTP 403 error code back at the client. I've read that HttpException is the cleanest way to accomplish this, but it's not working for me. I throw the exception from within a page like this: throw new HttpException(403,"You must be logged in to access this resource."); However, this will only give a standard ASP.Net stack trace(with 500 error) when CustomErro

抛出HttpException总是发回HTTP 500错误?

我试图在客户端抛出一个HTTP 403错误代码。 我读过HttpException是完成这个最简单的方法,但它不适合我。 我从这样的页面中抛出异常: throw new HttpException(403,"You must be logged in to access this resource."); 但是,这只会在CustomErrors关闭时提供标准的ASP.Net堆栈跟踪(500错误)。 如果CustomErrors打开,那么这将不会重定向到发生403错误时显示的页面。 我应该忘记HttpException,而是自己设置所有的HTTP

Parameter name: directoryVirtualPath

I am using Visual Studio Express 2012 RC. If a create a blank "hello world MVC 4.5 project" I Downgrade it to 4.0 so it is compatible with my host (Arvixe) I publish it to the host. And then i get this error message, i can find any information on it online. Server Error in '/' Application. Directory does not exist. Parameter name: directoryVirtualPath Description: An unhandle

参数名称:directoryVirtualPath

我正在使用Visual Studio Express 2012 RC。 如果创建一个空白的“hello world MVC 4.5 project” 我将它降级到4.0,因此它与我的主机(Arvixe)兼容 我将它发布给主机。 然后我得到这个错误信息,我可以在网上找到它的任何信息。 Server Error in '/' Application. Directory does not exist. Parameter name: directoryVirtualPath Description: An unhandled exception occurred during the execution of the current

Returning value from Parent

In the snippet below, a task creates two child tasks using the TaskCreationOptions.AttachedToParent, which means the parent task will wait for the child tasks to finish. Question is - why doesn't the parent task return correct value [102]? Does it first determine its return value and then wait for the child tasks to finish. If so, then what is the point of creating parent-child relationsh

从父母返回价值

在下面的代码片段中,任务使用TaskCreationOptions.AttachedToParent创建两个子任务,这意味着父任务将等待子任务完成。 问题是 - 为什么父任务没有返回正确的值[102]? 它是否首先确定其返回值,然后等待子任务完成。 如果是这样,那么创建亲子关系有什么意义呢? void Main() { Console.WriteLine ("Main start."); int i = 100; Task<int> t1 = new Task<int>(()=> { Console.WriteLine ("In parent

Allocating a new call stack

(I think there's a high chance of this question either being a duplicate or otherwise answered here already, but searching for the answer is hard thanks to interference from "stack allocation" and related terms.) I have a toy compiler I've been working on for a scripting language. In order to be able to pause the execution of a script while it's in progress and return to

分配一个新的调用堆栈

(我认为这个问题很可能是重复的或者在这里已经被回答了,但是由于来自“堆栈分配”和相关术语的干扰,搜索答案很困难。) 我有一个我一直在为脚本语言编写的玩具编译器。 为了能够在脚本执行过程中暂停执行并返回到主机程序,它有自己的堆栈:一个带有“堆栈指针”变量的简单内存块,使用正常的C代码操作进行递增对于那样的事情等等等等。 目前为止没有意思。 目前我编译为C.但我有兴趣研究编译为机器代码 - 同时保留次堆栈和

How to pass parameter to Microsoft Sync 2.1 generated Stored procedures

I am using Microsoft sync framework 2.1 version we are trying to implement database versioning ie if there is a table schema change in the server database, all or some client should be still able to sync their data without doing same schema changes or without taking an updated DB. At the higher level we need to maintain multiple application version for different clients with same sever DB. I

如何将参数传递给Microsoft Sync 2.1生成的存储过程

我正在使用Microsoft同步框架2.1版本 我们试图实现数据库版本控制,也就是说,如果服务器数据库中存在表格模式更改,则所有或某些客户端应该仍能够在不进行相同模式更改或不更新数据库的情况下同步其数据。 在更高层次上,我们需要为同一服务器数据库的不同客户端维护多个应用程序版本。 我试图将应用程序版本作为参数传递给所有存储过程,以便我可以处理多个客户端的数据版本。 我能够将参数传递给“select_chagnes”存储过

Prism module system from within WCF service?

Can you boostrap a Prism module system from within the WCF service? Because no matter what I do my MEF dependencies are not being fulfilled. Eg: This is my WCF service implementation public class MyService : IMyServiceContract{ // This should get filled by MEF after Prism loads the required modules [Import] IDatabase db; public MyService(){ var bootsrapper = new MyS

Prics模块系统从WCF服务内部?

你能从WCF服务中提升Prism模块系统吗? 因为不管我做什么我的MEF依赖没有得到满足。 例如: 这是我的WCF服务实现 public class MyService : IMyServiceContract{ // This should get filled by MEF after Prism loads the required modules [Import] IDatabase db; public MyService(){ var bootsrapper = new MyServiceBoostrapper(); bootsrapper.Run(); } } 这是我的MEF风格的Pr

interrupt execution of stored procedure

I am working on a C# application that calls stored procedures from a SQL server. Depending on the search parameters the user inputs, the stored procedure can take a while and return many records. I want to implement a cancel button so the user can cancel the execution of the stored procedure when it takes to long. I run the call to the stored procedure in a new thread so the GUI doesn't g

中断执行存储过程

我正在从一个SQL服务器调用存储过程的C#应用​​程序。 根据用户输入的搜索参数,存储过程可能需要一段时间并返回许多记录。 我想要实现一个取消按钮,这样用户可以在需要很长时间的时候取消存储过程的执行。 我在新线程中运行对存储过程的调用,以便在存储过程需要一段时间时GUI不会受到影响。 我读了关于中止一个线程,但发现许多拒绝有关使用中止的意见。 我想到的可能解决方案: 有没有一种常见的方式来停止执行存储

How to redirect to another page after a delay

I have a sign-in box in my webpage which is inside an UpdatePanel <asp:UpdatePanel runat="server" ClientIDMode="Static" ID="upSign" UpdateMode="Conditional"> <ContentTemplate> <div class="dvHolder hidOverflow clearfix"> <input id="txtSUser" type="text" name="SUsername" value="" placeholder="Username" runat="server" /> </div> &

如何在延迟后重定向到其他页面

我在UpdatePanel内的网页上有一个登录框 <asp:UpdatePanel runat="server" ClientIDMode="Static" ID="upSign" UpdateMode="Conditional"> <ContentTemplate> <div class="dvHolder hidOverflow clearfix"> <input id="txtSUser" type="text" name="SUsername" value="" placeholder="Username" runat="server" /> </div> <div class="dvHolder hidOv