I have a forms-based authentication application on our intranet - ASP.NET 3.5 (C#).
For security purposes there is one specific .aspx file that we have enabled Integrated Windows Authentication turned on. Administrators in another group control access to this .aspx file via the file system. They have specifically set DENY access on this file to a few groups of employees.
If one of those employees somehow manages to bring up that .aspx, they generate an exception (UnauthorizedAc cessException).
Without debating the merits of the above solution as it cannot be changed, my question is this: how do I go about trapping that exception and redirecting the user back to a page they can access?
According to the stack trace, it seems to be failing at the IO level, so I'm not sure exactly where to insert code to catch this exception and redirect the user back to the home page of the application. It doesn't seem to even touch any of the events on the .aspx, as I've tried going back as far as Page Init with no luck.
Would this be something I'd have to catch in a handler of some sort? I'm kinda lost on this one.
Here's the last bit of the trace:
Exception Details: System.Unauthor izedAccessExcep tion: Access to the path 'H:\InetPub\Int ranet\tracking. aspx' is denied.
[UnauthorizedAcc essException: Access to the path 'H:\InetPub\Int ranet\tracking. aspx' is denied.]
System.IO.__Err or.WinIOError(I nt32 errorCode, String maybeFullPath) +7712175
System.IO.FileS tream.Init(Stri ng path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIB UTES secAttrs, String msgPath, Boolean bFromProxy) +1162
System.IO.FileS tream..ctor(Str ing path, FileMode mode, FileAccess access, FileShare share) +66
System.Web.Host ing.MapPathBase dVirtualFile.Op en() +75
System.Web.Host ing.VirtualPath Provider.OpenFi le(String virtualPath) +28
System.Web.UI.T emplateParser.P arseFile(String physicalPath, VirtualPath virtualPath) +123
System.Web.UI.T emplateParser.P arseInternal() +58
System.Web.UI.T emplateParser.P arse() +167
For security purposes there is one specific .aspx file that we have enabled Integrated Windows Authentication turned on. Administrators in another group control access to this .aspx file via the file system. They have specifically set DENY access on this file to a few groups of employees.
If one of those employees somehow manages to bring up that .aspx, they generate an exception (UnauthorizedAc cessException).
Without debating the merits of the above solution as it cannot be changed, my question is this: how do I go about trapping that exception and redirecting the user back to a page they can access?
According to the stack trace, it seems to be failing at the IO level, so I'm not sure exactly where to insert code to catch this exception and redirect the user back to the home page of the application. It doesn't seem to even touch any of the events on the .aspx, as I've tried going back as far as Page Init with no luck.
Would this be something I'd have to catch in a handler of some sort? I'm kinda lost on this one.
Here's the last bit of the trace:
Exception Details: System.Unauthor izedAccessExcep tion: Access to the path 'H:\InetPub\Int ranet\tracking. aspx' is denied.
[UnauthorizedAcc essException: Access to the path 'H:\InetPub\Int ranet\tracking. aspx' is denied.]
System.IO.__Err or.WinIOError(I nt32 errorCode, String maybeFullPath) +7712175
System.IO.FileS tream.Init(Stri ng path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIB UTES secAttrs, String msgPath, Boolean bFromProxy) +1162
System.IO.FileS tream..ctor(Str ing path, FileMode mode, FileAccess access, FileShare share) +66
System.Web.Host ing.MapPathBase dVirtualFile.Op en() +75
System.Web.Host ing.VirtualPath Provider.OpenFi le(String virtualPath) +28
System.Web.UI.T emplateParser.P arseFile(String physicalPath, VirtualPath virtualPath) +123
System.Web.UI.T emplateParser.P arseInternal() +58
System.Web.UI.T emplateParser.P arse() +167
Comment