I have custom class that extends WebViewPage that I use as the base for all my Razor views using the method outlined here: http://haacked.com/archive/2011/02/21/changing-base-type-of-a-razor-view.aspx. Everything works fine unless I move it to a namespace that's different from the namespace of the views themselves whereupon the IntelliSense stops working (yes, I included the namespace of the custom WebViewPage in the namespaces section in the system.web.webPages.razor section of the web.config in the views folder). Is there a way around this?
What I want to do eventually is move all the views into another project that the graphic designers have access to, but I don't want the custom WebViewPage class in that project. Is this possible without breaking IntelliSense?
This is going to sound silly, but rebuild and restart Visual Studio a few times :-D
I just reproduced the issue, and tried everything to get it working (including changing pageBaseType in in addition to the one). I restarted VS, and it started working. Removed the part, and it still works after several clean/rebuild/restart cycles.
My Views/Web.config has this:
<system.web.webPages.razor>
<pages pageBaseType="ClassLibrary1.MyBasePage">
</system.web.webPages.razor>
My web project has a reference to the ClassLibrary1 project.
My custom class (in ClassLibrary1) looks like this:
namespace ClassLibrary1
{
public abstract class MyBasePage<T> : WebViewPage<T>
{
public string DannyName { get; set; }
public MyBasePage()
{
this.DannyName = "Danny Tuppeny";
}
}
}
And when in the web projects Views/Home/Index.cshtml, I get intellisense for "@DannyName" when I type "@D".
Some things I tried that might have had an effect, but it's still working after I removed it:
I found out that it's enough to restart your Cassini / IIS Express / IIS web server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With