Last time, we saw that there are severe limitations in creating ASPX pages which inherit generic base classes. Many readers were probably wondering how ASP.Net MVC works around this limitation. In ASP.Net MVC views, people write pages like this all the time:
<%@ Page Language="C#" Inherits="ViewPage<IEnumerable<DataLayer.Product>>" %>
ASP.Net MVC includes its own workaround for these limitations. The Web.config file in the Views folder of an ASP.Net MVC project registers a PageParserFilter:
<pages validateRequest="false" pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" ...> ... </pages>
PageParserFilter is one of ASP.Net’s lesser-known extensibility points. It can intercept different parts in the parsing process for an ASPX page and modify the page. The MVC framework’s ViewTypeParserFilter will check whether the page’s inherits=""
attribute contains (
or a <
characters; these characters can only appear in C# or VB.Net generic types, but not in the CLR’s native syntax.
If the inherits=""
attribute contains these characters, it will save the attribute’s original value, then replace it with ViewPage
(Or ViewMasterPage
or ViewUserControl
, as appropriate). This way, the rest of the built-in ASP.Net parser will see a normal type name that it knows how to parse. After the page finishes parsing, an internal ControlBuilder registered on MVC’s base types (ViewPage
, ViewMasterPage
or ViewUserControl
) will replace the base type in the generated CodeDOM tree with the original value of the inherits=""
attribute.
The one problem with the hack is that it leaves the ASPX parsing engine unaware of the page’s actual base type. Therefore, if you make a page that inherits a generic base class with additional properties, you won’t be able to set those properties in the <%@ Page
declaration (since the ASPX parser won’t know about them). If you inherit a non-generic type, this mechanism will not kick in and page properties will work fine.
16 comments:
Thank you very much.
It's good that someone is writing about it. Stella
wow... what a great blog, Mobilism simcity buildit mod apk dead trigger mod apk
Vajinismus Thanks.
In my opinion, this information will help you to learn more bout writing American dream essay. It will help you to achieve success in college
شركة تنظيف كنب بمكة بالبخار
تنظيف بمكة شركة تنظيف بمكة بالبخار
mr jatt Mp3 New Punjabi Song,Single Tracks Latest song download also Listen Latest Music Albums Online in High Quality at Mrpendus.in
mr jatt
Thank you.
izmir üroloji
izmir ürolog
Very impressive blog post, I subscribed your blog for your future post. I also have some useful link to share here mcafee activate |
mcafee.com/activate |
norton.com/setup |
norton setup |
office.com/setup |
Good Work, i like the way you describe this topic, keep going. i would like to share some useful security links here please go through www.mcafee.com/activate |
www.norton.com/setup |
www.office.com/setup |
office setup |
This is really great work , Thank you for sharing such a useful information here in the blog. I have something to share here mcafee download |
norton download |
microsoft office download |
office download |
دانلود آهنگ جدید ایرانی و ترکی با بهترین کیفیت و لینک مستقیم از سایت موزیکدل
If i will tell you , I was really in need of MVC's. I have been assigned a project which uses MVC. Thank you for sharing this article.
office.com/setup
asp.net is the frame work. you develop GUI on the asp.net very easily.
office.com/setup
I really appreciate the way you write...Please check my work as well
Jaipur Call Girl
Jaipur Call Girl
Jaipur Call Girl
Delhi Call Girl
Guwahati Call Girl
Guwahati Call Girl
Guwahati Call Girl
Guwahati Call Girl
Aerocity Call Girl
Lucknow Call Girl
Post a Comment