|
|
|
Kornél Pál
|
Hi,
These two internal types are present in all .NET Framework versions. HttpNotFoundHandler is exposed by default Web.config in .NET Framework 2.0. HttpNotImplementedHandler is documented in book Professional ASP.NET 2.0 Security, Membership, and Role Management, page 66: http://books.google.com/books?id=Qt3TeJJkG5oC Kornél Index: mcs/class/System.Web/System.Web/HttpNotImplementedHandler.cs =================================================================== --- mcs/class/System.Web/System.Web/HttpNotImplementedHandler.cs (revision 0) +++ mcs/class/System.Web/System.Web/HttpNotImplementedHandler.cs (revision 0) @@ -0,0 +1,46 @@ +// +// System.Web.HttpNotImplementedHandler.cs +// +// Author: +// Kornél Pál <http://www.kornelpal.com/> +// +// Copyright (C) 2009 Kornél Pál +// + +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +namespace System.Web +{ + internal class HttpNotImplementedHandler : IHttpHandler + { + public void ProcessRequest (HttpContext context) + { + HttpRequest request = context.Request; + + throw new HttpException (501, request.HttpMethod + " " + request.Path + " is not implemented."); + } + + public bool IsReusable { + get { return true; } + } + } +} Property changes on: mcs\class\System.Web\System.Web\HttpNotImplementedHandler.cs ___________________________________________________________________ Name: svn:eol-style + native Index: mcs/class/System.Web/System.Web/HttpNotFoundHandler.cs =================================================================== --- mcs/class/System.Web/System.Web/HttpNotFoundHandler.cs (revision 0) +++ mcs/class/System.Web/System.Web/HttpNotFoundHandler.cs (revision 0) @@ -0,0 +1,46 @@ +// +// System.Web.HttpNotFoundHandler.cs +// +// Author: +// Kornél Pál <http://www.kornelpal.com/> +// +// Copyright (C) 2009 Kornél Pál +// + +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +namespace System.Web +{ + internal class HttpNotFoundHandler : IHttpHandler + { + public void ProcessRequest (HttpContext context) + { + string path = context.Request.Path; + + throw new HttpException (404, "Path '" + path + "' was not found.", path); + } + + public bool IsReusable { + get { return true; } + } + } +} Property changes on: mcs\class\System.Web\System.Web\HttpNotFoundHandler.cs ___________________________________________________________________ Name: svn:eol-style + native Index: mcs/class/System.Web/System.Web20.csproj =================================================================== --- mcs/class/System.Web/System.Web20.csproj (revision 135657) +++ mcs/class/System.Web/System.Web20.csproj (working copy) @@ -1091,6 +1091,8 @@ <SubType>Code</SubType> </Compile> <Compile Include="System.Web\HttpModuleCollection.cs" /> + <Compile Include="System.Web\HttpNotFoundHandler.cs" /> + <Compile Include="System.Web\HttpNotImplementedHandler.cs" /> <Compile Include="System.Web\HttpParseException.cs" /> <Compile Include="System.Web\HttpPostedFile.cs" /> <Compile Include="System.Web\HttpRequest.cs" /> Index: mcs/class/System.Web/System.Web.dll.sources =================================================================== --- mcs/class/System.Web/System.Web.dll.sources (revision 135657) +++ mcs/class/System.Web/System.Web.dll.sources (working copy) @@ -316,6 +316,8 @@ System.Web/HttpForbiddenHandler.cs System.Web/HttpMethodNotAllowedHandler.cs System.Web/HttpModuleCollection.cs +System.Web/HttpNotFoundHandler.cs +System.Web/HttpNotImplementedHandler.cs System.Web/HttpParamsCollection.cs System.Web/HttpParseException.cs System.Web/HttpPostedFile.cs _______________________________________________ Mono-devel-list mailing list [hidden email] http://lists.ximian.com/mailman/listinfo/mono-devel-list |
||||||||||||||||
|
Kornél Pál
|
I've received no comments or approval please review and if you like it,
approve the patch. Thanks. Kornél Kornél Pál wrote: > Hi, > > These two internal types are present in all .NET Framework versions. > > HttpNotFoundHandler is exposed by default Web.config in .NET Framework 2.0. > > HttpNotImplementedHandler is documented in book Professional ASP.NET 2.0 > Security, Membership, and Role Management, page 66: > http://books.google.com/books?id=Qt3TeJJkG5oC > > Kornél > Index: mcs/class/System.Web/System.Web/HttpNotImplementedHandler.cs =================================================================== --- mcs/class/System.Web/System.Web/HttpNotImplementedHandler.cs (revision 0) +++ mcs/class/System.Web/System.Web/HttpNotImplementedHandler.cs (revision 0) @@ -0,0 +1,46 @@ +// +// System.Web.HttpNotImplementedHandler.cs +// +// Author: +// Kornél Pál <http://www.kornelpal.com/> +// +// Copyright (C) 2009 Kornél Pál +// + +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +namespace System.Web +{ + internal class HttpNotImplementedHandler : IHttpHandler + { + public void ProcessRequest (HttpContext context) + { + HttpRequest request = context.Request; + + throw new HttpException (501, request.HttpMethod + " " + request.Path + " is not implemented."); + } + + public bool IsReusable { + get { return true; } + } + } +} Property changes on: mcs\class\System.Web\System.Web\HttpNotImplementedHandler.cs ___________________________________________________________________ Name: svn:eol-style + native Index: mcs/class/System.Web/System.Web/HttpNotFoundHandler.cs =================================================================== --- mcs/class/System.Web/System.Web/HttpNotFoundHandler.cs (revision 0) +++ mcs/class/System.Web/System.Web/HttpNotFoundHandler.cs (revision 0) @@ -0,0 +1,46 @@ +// +// System.Web.HttpNotFoundHandler.cs +// +// Author: +// Kornél Pál <http://www.kornelpal.com/> +// +// Copyright (C) 2009 Kornél Pál +// + +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +namespace System.Web +{ + internal class HttpNotFoundHandler : IHttpHandler + { + public void ProcessRequest (HttpContext context) + { + string path = context.Request.Path; + + throw new HttpException (404, "Path '" + path + "' was not found.", path); + } + + public bool IsReusable { + get { return true; } + } + } +} Property changes on: mcs\class\System.Web\System.Web\HttpNotFoundHandler.cs ___________________________________________________________________ Name: svn:eol-style + native Index: mcs/class/System.Web/System.Web20.csproj =================================================================== --- mcs/class/System.Web/System.Web20.csproj (revision 135657) +++ mcs/class/System.Web/System.Web20.csproj (working copy) @@ -1091,6 +1091,8 @@ <SubType>Code</SubType> </Compile> <Compile Include="System.Web\HttpModuleCollection.cs" /> + <Compile Include="System.Web\HttpNotFoundHandler.cs" /> + <Compile Include="System.Web\HttpNotImplementedHandler.cs" /> <Compile Include="System.Web\HttpParseException.cs" /> <Compile Include="System.Web\HttpPostedFile.cs" /> <Compile Include="System.Web\HttpRequest.cs" /> Index: mcs/class/System.Web/System.Web.dll.sources =================================================================== --- mcs/class/System.Web/System.Web.dll.sources (revision 135657) +++ mcs/class/System.Web/System.Web.dll.sources (working copy) @@ -316,6 +316,8 @@ System.Web/HttpForbiddenHandler.cs System.Web/HttpMethodNotAllowedHandler.cs System.Web/HttpModuleCollection.cs +System.Web/HttpNotFoundHandler.cs +System.Web/HttpNotImplementedHandler.cs System.Web/HttpParamsCollection.cs System.Web/HttpParseException.cs System.Web/HttpPostedFile.cs _______________________________________________ Mono-devel-list mailing list [hidden email] http://lists.ximian.com/mailman/listinfo/mono-devel-list |
||||||||||||||||
|
Miguel de Icaza
|
Hello Kornél,
I am not sure why we would include in Mono two classes that are flagged as internal. How would a user even use this? On Nov 1, 2009, at 11:23 AM, Kornél Pál wrote: > I've received no comments or approval please review and if you like > it, > approve the patch. > > Thanks. > > Kornél > > Kornél Pál wrote: >> Hi, >> These two internal types are present in all .NET Framework versions. >> HttpNotFoundHandler is exposed by default Web.config in .NET >> Framework 2.0. >> HttpNotImplementedHandler is documented in book Professional >> ASP.NET 2.0 Security, Membership, and Role Management, page 66: >> http://books.google.com/books?id=Qt3TeJJkG5oC >> Kornél > > > Index: mcs/class/System.Web/System.Web/HttpNotImplementedHandler.cs > =================================================================== > --- mcs/class/System.Web/System.Web/HttpNotImplementedHandler.cs > (revision 0) > +++ mcs/class/System.Web/System.Web/HttpNotImplementedHandler.cs > (revision 0) > @@ -0,0 +1,46 @@ > +// > +// System.Web.HttpNotImplementedHandler.cs > +// > +// Author: > +// Kornél Pál <http://www.kornelpal.com/> > +// > +// Copyright (C) 2009 Kornél Pál > +// > + > +// > +// Permission is hereby granted, free of charge, to any person > obtaining > +// a copy of this software and associated documentation files (the > +// "Software"), to deal in the Software without restriction, > including > +// without limitation the rights to use, copy, modify, merge, > publish, > +// distribute, sublicense, and/or sell copies of the Software, and to > +// permit persons to whom the Software is furnished to do so, > subject to > +// the following conditions: > +// > +// The above copyright notice and this permission notice shall be > +// included in all copies or substantial portions of the Software. > +// > +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, > +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF > +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND > +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT > HOLDERS BE > +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN > ACTION > +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN > CONNECTION > +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. > +// > + > +namespace System.Web > +{ > + internal class HttpNotImplementedHandler : IHttpHandler > + { > + public void ProcessRequest (HttpContext context) > + { > + HttpRequest request = context.Request; > + > + throw new HttpException (501, request.HttpMethod + " " + > request.Path + " is not implemented."); > + } > + > + public bool IsReusable { > + get { return true; } > + } > + } > +} > > Property changes on: mcs\class\System.Web\System.Web > \HttpNotImplementedHandler.cs > ___________________________________________________________________ > Name: svn:eol-style > + native > > Index: mcs/class/System.Web/System.Web/HttpNotFoundHandler.cs > =================================================================== > --- mcs/class/System.Web/System.Web/HttpNotFoundHandler.cs (revision > 0) > +++ mcs/class/System.Web/System.Web/HttpNotFoundHandler.cs (revision > 0) > @@ -0,0 +1,46 @@ > +// > +// System.Web.HttpNotFoundHandler.cs > +// > +// Author: > +// Kornél Pál <http://www.kornelpal.com/> > +// > +// Copyright (C) 2009 Kornél Pál > +// > + > +// > +// Permission is hereby granted, free of charge, to any person > obtaining > +// a copy of this software and associated documentation files (the > +// "Software"), to deal in the Software without restriction, > including > +// without limitation the rights to use, copy, modify, merge, > publish, > +// distribute, sublicense, and/or sell copies of the Software, and to > +// permit persons to whom the Software is furnished to do so, > subject to > +// the following conditions: > +// > +// The above copyright notice and this permission notice shall be > +// included in all copies or substantial portions of the Software. > +// > +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, > +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF > +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND > +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT > HOLDERS BE > +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN > ACTION > +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN > CONNECTION > +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. > +// > + > +namespace System.Web > +{ > + internal class HttpNotFoundHandler : IHttpHandler > + { > + public void ProcessRequest (HttpContext context) > + { > + string path = context.Request.Path; > + > + throw new HttpException (404, "Path '" + path + "' was not > found.", path); > + } > + > + public bool IsReusable { > + get { return true; } > + } > + } > +} > > Property changes on: mcs\class\System.Web\System.Web > \HttpNotFoundHandler.cs > ___________________________________________________________________ > Name: svn:eol-style > + native > > Index: mcs/class/System.Web/System.Web20.csproj > =================================================================== > --- mcs/class/System.Web/System.Web20.csproj (revision 135657) > +++ mcs/class/System.Web/System.Web20.csproj (working copy) > @@ -1091,6 +1091,8 @@ > <SubType>Code</SubType> > </Compile> > <Compile Include="System.Web\HttpModuleCollection.cs" /> > + <Compile Include="System.Web\HttpNotFoundHandler.cs" /> > + <Compile Include="System.Web\HttpNotImplementedHandler.cs" /> > <Compile Include="System.Web\HttpParseException.cs" /> > <Compile Include="System.Web\HttpPostedFile.cs" /> > <Compile Include="System.Web\HttpRequest.cs" /> > Index: mcs/class/System.Web/System.Web.dll.sources > =================================================================== > --- mcs/class/System.Web/System.Web.dll.sources (revision 135657) > +++ mcs/class/System.Web/System.Web.dll.sources (working copy) > @@ -316,6 +316,8 @@ > System.Web/HttpForbiddenHandler.cs > System.Web/HttpMethodNotAllowedHandler.cs > System.Web/HttpModuleCollection.cs > +System.Web/HttpNotFoundHandler.cs > +System.Web/HttpNotImplementedHandler.cs > System.Web/HttpParamsCollection.cs > System.Web/HttpParseException.cs > System.Web/HttpPostedFile.cs > _______________________________________________ > Mono-devel-list mailing list > [hidden email] > http://lists.ximian.com/mailman/listinfo/mono-devel-list _______________________________________________ Mono-devel-list mailing list [hidden email] http://lists.ximian.com/mailman/listinfo/mono-devel-list |
||||||||||||||||
|
Kornél Pál
|
Miguel de Icaza wrote:
> I am not sure why we would include in Mono two classes that are > flagged as internal. How would a user even use this? Handlers are mostly used in Web.config and the ASP.NET runtime uses reflection that makes it able to instantiate non-public types. This way users may not even realize that they are using internal types. On the other hand if you want to hide or deny requests you can use just like HttpForbiddenHandler but you can have additional HTTP status codes and messages. Of course you could duplicate this functionality in your own classes but it's easier to use existing framework classes. I just realized that Microsoft documented HttpForbiddenHandler that is internal as well and is implemented in Mono: http://msdn.microsoft.com/en-us/library/ms404282.aspx Originally HttpForbiddenHandler was exposed only in Web.config. HttpNotFoundHandler existed in 1.x but was not exposed in Web.config until 2.0. So people most likely know that these types exist and the might use them. I actually wanted to use it when I found out that we haven't had it. HttpNotImplementedHandler is not used in Web.config and is most likely known by much less people but I found it in the prevously referenced book so I just implemented that as well to make the internal simple handler collection complete. Kornél _______________________________________________ Mono-devel-list mailing list [hidden email] http://lists.ximian.com/mailman/listinfo/mono-devel-list |
||||||||||||||||
|
Marek Habersack
|
In reply to this post
by Miguel de Icaza
Miguel de Icaza wrote:
Hello, > Hello Kornél, > > I am not sure why we would include in Mono two classes that are > flagged as internal. How would a user even use this? There are a few internal classes we refer to outside System.Web (in the global web.config - e.g. StaticFileHandler, HttpForbiddenHandler, HttpMethodNotAllowedHandler, all the build providers etc) but I also don't see a point in including classes we do not use in any such way. Kornél, is there any known external use of those classes in .NET? marek > > On Nov 1, 2009, at 11:23 AM, Kornél Pál wrote: > >> I've received no comments or approval please review and if you like >> it, >> approve the patch. >> >> Thanks. >> >> Kornél >> >> Kornél Pál wrote: >>> Hi, >>> These two internal types are present in all .NET Framework versions. >>> HttpNotFoundHandler is exposed by default Web.config in .NET >>> Framework 2.0. >>> HttpNotImplementedHandler is documented in book Professional >>> ASP.NET 2.0 Security, Membership, and Role Management, page 66: >>> http://books.google.com/books?id=Qt3TeJJkG5oC >>> Kornél >> >> Index: mcs/class/System.Web/System.Web/HttpNotImplementedHandler.cs >> =================================================================== >> --- mcs/class/System.Web/System.Web/HttpNotImplementedHandler.cs >> (revision 0) >> +++ mcs/class/System.Web/System.Web/HttpNotImplementedHandler.cs >> (revision 0) >> @@ -0,0 +1,46 @@ >> +// >> +// System.Web.HttpNotImplementedHandler.cs >> +// >> +// Author: >> +// Kornél Pál <http://www.kornelpal.com/> >> +// >> +// Copyright (C) 2009 Kornél Pál >> +// >> + >> +// >> +// Permission is hereby granted, free of charge, to any person >> obtaining >> +// a copy of this software and associated documentation files (the >> +// "Software"), to deal in the Software without restriction, >> including >> +// without limitation the rights to use, copy, modify, merge, >> publish, >> +// distribute, sublicense, and/or sell copies of the Software, and to >> +// permit persons to whom the Software is furnished to do so, >> subject to >> +// the following conditions: >> +// >> +// The above copyright notice and this permission notice shall be >> +// included in all copies or substantial portions of the Software. >> +// >> +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, >> +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF >> +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND >> +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT >> HOLDERS BE >> +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN >> ACTION >> +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN >> CONNECTION >> +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. >> +// >> + >> +namespace System.Web >> +{ >> + internal class HttpNotImplementedHandler : IHttpHandler >> + { >> + public void ProcessRequest (HttpContext context) >> + { >> + HttpRequest request = context.Request; >> + >> + throw new HttpException (501, request.HttpMethod + " " + >> request.Path + " is not implemented."); >> + } >> + >> + public bool IsReusable { >> + get { return true; } >> + } >> + } >> +} >> >> Property changes on: mcs\class\System.Web\System.Web >> \HttpNotImplementedHandler.cs >> ___________________________________________________________________ >> Name: svn:eol-style >> + native >> >> Index: mcs/class/System.Web/System.Web/HttpNotFoundHandler.cs >> =================================================================== >> --- mcs/class/System.Web/System.Web/HttpNotFoundHandler.cs (revision >> 0) >> +++ mcs/class/System.Web/System.Web/HttpNotFoundHandler.cs (revision >> 0) >> @@ -0,0 +1,46 @@ >> +// >> +// System.Web.HttpNotFoundHandler.cs >> +// >> +// Author: >> +// Kornél Pál <http://www.kornelpal.com/> >> +// >> +// Copyright (C) 2009 Kornél Pál >> +// >> + >> +// >> +// Permission is hereby granted, free of charge, to any person >> obtaining >> +// a copy of this software and associated documentation files (the >> +// "Software"), to deal in the Software without restriction, >> including >> +// without limitation the rights to use, copy, modify, merge, >> publish, >> +// distribute, sublicense, and/or sell copies of the Software, and to >> +// permit persons to whom the Software is furnished to do so, >> subject to >> +// the following conditions: >> +// >> +// The above copyright notice and this permission notice shall be >> +// included in all copies or substantial portions of the Software. >> +// >> +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, >> +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF >> +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND >> +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT >> HOLDERS BE >> +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN >> ACTION >> +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN >> CONNECTION >> +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. >> +// >> + >> +namespace System.Web >> +{ >> + internal class HttpNotFoundHandler : IHttpHandler >> + { >> + public void ProcessRequest (HttpContext context) >> + { >> + string path = context.Request.Path; >> + >> + throw new HttpException (404, "Path '" + path + "' was not >> found.", path); >> + } >> + >> + public bool IsReusable { >> + get { return true; } >> + } >> + } >> +} >> >> Property changes on: mcs\class\System.Web\System.Web >> \HttpNotFoundHandler.cs >> ___________________________________________________________________ >> Name: svn:eol-style >> + native >> >> Index: mcs/class/System.Web/System.Web20.csproj >> =================================================================== >> --- mcs/class/System.Web/System.Web20.csproj (revision 135657) >> +++ mcs/class/System.Web/System.Web20.csproj (working copy) >> @@ -1091,6 +1091,8 @@ >> <SubType>Code</SubType> >> </Compile> >> <Compile Include="System.Web\HttpModuleCollection.cs" /> >> + <Compile Include="System.Web\HttpNotFoundHandler.cs" /> >> + <Compile Include="System.Web\HttpNotImplementedHandler.cs" /> >> <Compile Include="System.Web\HttpParseException.cs" /> >> <Compile Include="System.Web\HttpPostedFile.cs" /> >> <Compile Include="System.Web\HttpRequest.cs" /> >> Index: mcs/class/System.Web/System.Web.dll.sources >> =================================================================== >> --- mcs/class/System.Web/System.Web.dll.sources (revision 135657) >> +++ mcs/class/System.Web/System.Web.dll.sources (working copy) >> @@ -316,6 +316,8 @@ >> System.Web/HttpForbiddenHandler.cs >> System.Web/HttpMethodNotAllowedHandler.cs >> System.Web/HttpModuleCollection.cs >> +System.Web/HttpNotFoundHandler.cs >> +System.Web/HttpNotImplementedHandler.cs >> System.Web/HttpParamsCollection.cs >> System.Web/HttpParseException.cs >> System.Web/HttpPostedFile.cs >> _______________________________________________ >> Mono-devel-list mailing list >> [hidden email] >> http://lists.ximian.com/mailman/listinfo/mono-devel-list > > _______________________________________________ > Mono-devel-list mailing list > [hidden email] > http://lists.ximian.com/mailman/listinfo/mono-devel-list > _______________________________________________ Mono-devel-list mailing list [hidden email] http://lists.ximian.com/mailman/listinfo/mono-devel-list |
||||||||||||||||
|
Marek Habersack
|
In reply to this post
by Kornél Pál
Kornél Pál wrote:
> Miguel de Icaza wrote: >> I am not sure why we would include in Mono two classes that are >> flagged as internal. How would a user even use this? > > Handlers are mostly used in Web.config and the ASP.NET runtime uses > reflection that makes it able to instantiate non-public types. This way > users may not even realize that they are using internal types. True, but this is not the case for the two types you implemented. > On the other hand if you want to hide or deny requests you can use just > like HttpForbiddenHandler but you can have additional HTTP status codes > and messages. > > Of course you could duplicate this functionality in your own classes but > it's easier to use existing framework classes. That's what we do now. > I just realized that Microsoft documented HttpForbiddenHandler that is > internal as well and is implemented in Mono: > http://msdn.microsoft.com/en-us/library/ms404282.aspx > > Originally HttpForbiddenHandler was exposed only in Web.config. > HttpNotFoundHandler existed in 1.x but was not exposed in Web.config > until 2.0. Ah, indeed, just looked at .NET 3.5 config and it's there. I'm ok with putting in System.Web in that case (modify the global web.config as well, to reference the type in the same fashion as .NET) > So people most likely know that these types exist and the might use > them. I actually wanted to use it when I found out that we haven't had it. That, in itself, is not a good argument - most Windows developers who work with .NET probably use Reflector to dig into .NET internals, so they are aware of many internal types/fields/methods - we won't implement features based on that knowledge, at least I don't think it's a good idea. > HttpNotImplementedHandler is not used in Web.config and is most likely > known by much less people but I found it in the prevously referenced > book so I just implemented that as well to make the internal simple > handler collection complete. I don't think we should include it just for the sake of it. If you want it in, that's fine, but you need to modify all the spots in System.Web code which throw 404 and make sure there are no regressions in exception/error handling because of that. Only then the type can be included. marek > > Kornél > _______________________________________________ > Mono-devel-list mailing list > [hidden email] > http://lists.ximian.com/mailman/listinfo/mono-devel-list > _______________________________________________ Mono-devel-list mailing list [hidden email] http://lists.ximian.com/mailman/listinfo/mono-devel-list |
||||||||||||||||
|
Kornél Pál
|
Marek Habersack wrote:
>> HttpNotImplementedHandler is not used in Web.config and is most likely >> known by much less people but I found it in the prevously referenced >> book so I just implemented that as well to make the internal simple >> handler collection complete. > I don't think we should include it just for the sake of it. If you want > it in, that's fine, but you need to modify all the spots in System.Web > code which throw 404 and make sure there are no regressions in > exception/error handling because of that. Only then the type can be > included. These handlers need no special treatment. ASP.NET runtime should be and according to my experiences is able to receive HttpExceptions with status codes from handlers/user code. Only 403 and 404 codes are treated specially, that means a more destrictive error page, but that should not make any distinction based on the origin of the exception, just the status code. No maintenance requirements come with these two handlers. They just should be treated just like any other external handler. Their sole purpose is to throw HttpExceptions with the respective status code. Kornél _______________________________________________ Mono-devel-list mailing list [hidden email] http://lists.ximian.com/mailman/listinfo/mono-devel-list |
||||||||||||||||
|
Marek Habersack
|
Kornél Pál wrote:
> Marek Habersack wrote: >>> HttpNotImplementedHandler is not used in Web.config and is most >>> likely known by much less people but I found it in the prevously >>> referenced book so I just implemented that as well to make the >>> internal simple handler collection complete. >> I don't think we should include it just for the sake of it. If you >> want it in, that's fine, but you need to modify all the spots in >> System.Web code which throw 404 and make sure there are no regressions >> in exception/error handling because of that. Only then the type can be >> included. > > These handlers need no special treatment. ASP.NET runtime should be and > according to my experiences is able to receive HttpExceptions with > status codes from handlers/user code. in System.Web for the sake of matching .NET internals. If you want an internal type like this in System.Web, please make some use of it. > Only 403 and 404 codes are treated specially, that means a more > destrictive error page, but that should not make any distinction based > on the origin of the exception, just the status code. That's the theory, yes - I'd like to be sure in practice that there are no regressions from introducing a new type for 404. > No maintenance requirements come with these two handlers. They just > should be treated just like any other external handler. Their sole > purpose is to throw HttpExceptions with the respective status code. Once again, that's fine - but if we include them, I want them to be used and not just sit there. Code which isn't used is likely to erode with time (even if it's as simple as the code you posted) and we want to avoid that. marek _______________________________________________ Mono-devel-list mailing list [hidden email] http://lists.ximian.com/mailman/listinfo/mono-devel-list |
||||||||||||||||
|
Miguel de Icaza
|
Hello,
I think we want to get the patch in for the thing that can be referenced from Web.config; I do not care about the exception class, it is too much work to make it remotely useful. Miguel. On Nov 2, 2009, at 4:28 AM, Marek Habersack wrote: > Kornél Pál wrote: >> Marek Habersack wrote: >>>> HttpNotImplementedHandler is not used in Web.config and is most >>>> likely known by much less people but I found it in the prevously >>>> referenced book so I just implemented that as well to make the >>>> internal simple handler collection complete. >>> I don't think we should include it just for the sake of it. If you >>> want it in, that's fine, but you need to modify all the spots in >>> System.Web code which throw 404 and make sure there are no >>> regressions >>> in exception/error handling because of that. Only then the type >>> can be >>> included. >> >> These handlers need no special treatment. ASP.NET runtime should be >> and >> according to my experiences is able to receive HttpExceptions with >> status codes from handlers/user code. > Yes, it is able to do that, but that's not my point. I don't want > practically unused internal code > in System.Web for the sake of matching .NET internals. If you want > an internal type like this in > System.Web, please make some use of it. > >> Only 403 and 404 codes are treated specially, that means a more >> destrictive error page, but that should not make any distinction >> based >> on the origin of the exception, just the status code. > That's the theory, yes - I'd like to be sure in practice that there > are no regressions from > introducing a new type for 404. > >> No maintenance requirements come with these two handlers. They just >> should be treated just like any other external handler. Their sole >> purpose is to throw HttpExceptions with the respective status code. > Once again, that's fine - but if we include them, I want them to be > used and not just sit there. > Code which isn't used is likely to erode with time (even if it's as > simple as the code you posted) > and we want to avoid that. > > marek > _______________________________________________ > Mono-devel-list mailing list > [hidden email] > http://lists.ximian.com/mailman/listinfo/mono-devel-list _______________________________________________ Mono-devel-list mailing list [hidden email] http://lists.ximian.com/mailman/listinfo/mono-devel-list |
||||||||||||||||
| Free Embeddable Forum Powered by Nabble | Help |