A Base page in ASP.NET -


do recommend every web site created in visual studio, should create base page serves parent class?

what exact benefits/drawbacks?

if want override way in asp.net works, can more efficient build base class rather including code in every page. 2 specific instances i've done are:

ispostback
little-known fact: it's quite feasible craft request that, asp.net, looks postback submitted request. this? hackers, that's who. call ispostback in case return true, shoud return false. round this, build base class overrides ispostback:

public class mybase     inherits system.web.ui.page     <debuggerstepthrough()> _     public shadows function ispostback() boolean          'check built-in ispostback , make sure http post         return (page.ispostback andalso request.httpmethod.toupper = "post")      end function  end class 

error handling
in beginning asp.net security, blowdart talks fact if use asp.net's error handling redirect client custom error page, hackers (again) can detect redirection , flag error may exploitable. more secure pattern handle page's error event , server.transfer (which doesn't send client). again, doing in base class means write code once:

public partial mybase : system.web.ui.page {     protected void page_error (object sender, eventargs e)     {         exception ex = server.getlasterror();          // exception e.g. log         ...          server.transfer("~/mycustomerrorpage.aspx");      } } 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -