Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Razor - how to cast from this.Page (dynamic WebPageBase.Page) to System.Web.UI.Page

I'm trying to use DotNetOpenAuth with Razor/MVC3. Most of DotNetOpenAuth HTML helpers are accepting System.Web.UI.Page as one of parameters, which works fine standard using WebForms engine but does not with Razor. Is it possible to cast dynamic WebPageBase.Page into System.Web.UI.Page somehow?

Thanks, Antonin

like image 404
Antonin Jelinek Avatar asked Oct 11 '25 12:10

Antonin Jelinek


2 Answers

System.Web.UI.Page is part of the Web Forms page model and is totally unrelated to Razor. A Razor page inherits from System.Web.WebPages.WebPage which isn't part of the same hierarchy. As GvS mentioned, the "Page" property is a different object in Razor. In Razor, that property is just a C# dynamic object that provides a shortcut for accessing PageData values. For example: PageData["foo"] is the same as Page.foo.

like image 176
Andrew Stanton-Nurse Avatar answered Oct 16 '25 06:10

Andrew Stanton-Nurse


They are totally different objects. So, no, you cannot cast or convert into a System.Web.UI.Page.

But this article might help you further.

like image 26
GvS Avatar answered Oct 16 '25 08:10

GvS



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!