Include aspx in the static analysis (FxCop) of an MVC website - visual-studio-2010

I am doing static analysis for a MVC v2 website build with .net 4. I have compiled the website and ran FxCop on the resulting dll, but then I realized that the dll does not contain the code in the views (I used a reflector to determine that).
So the question is:
Can one configure the MVC project so that the views are published in a DLL that can be scanned?

You could precompile views by setting the following in the .csproj:
<MvcBuildViews>true</MvcBuildViews>

Related

Migrating .net framework to .netcore 3.1 (Servicestack.Razor Views)

I'm migrating a .net framework web to .netcore
Having issues with moving the 'Views' folder. It seems that every razor page with
#inherits ViewPage<TModel>
I get an error "The type or namespace 'ViewPage<>' could not be found (are you missing a using directive or an assembly reference?).
I've installed ServiceStack.Razor and ServiceStack.Mvc nuget package in my project but it's not able to recognize it in Views folder.
On my _ViewImports.cshtml, I have also added #using package references
Also, I am using 'Request.[]' from ServiceStack.Razor but it's unable to recognize Request.
Any ideas of what I'm missing? Should I be updating it to #model instead? When I update to #model it's working fine but 'Request' is still unrecognized
Unlike most features in ServiceStack which could be ported and multi-targeted to support both .NET Framework and .NET Core, ServiceStack.Razor's coupling to System.Web could not support .NET Core.
Instead ServiceStack.Razor for .NET Core was rewritten to work on top of ASP.NET Core MVC which is only contained in the ServiceStack.Mvc package not the the .NET Framework only ServiceStack.Razor package (which shouldn't be referenced in .NET Core).
Most of the syntax remained the same so porting should still require a small amount of effort as seen in ServiceStack.Razor's Razor Rockstars .NET Core port vs the original .NET Framework:
Razor Rockstars .NET Core
Razor Rockstars for .NET Framework
But given that it's a rewrite that works on top of ASP.NET Core MVC I wouldn't try to convert your existing ServiceStack.Razor project but instead to start with an empty new razor project so it starts from a well-known working configuration and then copying your existing Razor Views and Services across to the new project.
You can create a razor project via either the command-line:
$ x new razor ProjectName
Or using ServiceStack's online project template creator at: https://servicestack.net/start

Making MVC templates available in a Class Library (VS 2017)

I have an Umbraco Cloud project I am working on in Visual Studio. Umbraco Cloud provides a script that creates a Visual Studio solution consisting of two projects: An MVC website containing the CMS' files, and a Class Library for the developer's own MVC code. The Class Library project contains a Controllers and a Models folder.
The problem I am having is that Visual Studio's MVC templates are not available from within the Class Library project. When I choose Add > New Item, I get many templates under "Visual C# Items" the Installed list, but nothing for MVC.
I understand that these templates are not needed to create MVC code, but they are helpful for me, and their absence is an inconvenience.
How can I make Visual Studio's MVC templates available in this Class Library project? I looked through this site for solutions, but came up with nothing. Any help is appreciated.
Thanks,
David

Asp.net mvc Files required for deployment aren't reference in the project during development

After reading quite few articles on deployment, i am bit confused about the procedure.
All the articles refer to dlls which aren't reference in Asp.net mvc project. The dlls are like following :-
Microsoft.Web.Infrastructure.dll
System.Web.Razor.dll
System.Web.WebPages.Deployment.dll
System.Web.WebPages.Razor.dll
I created the MVC Music Store application from a tutorial on asp.net website and it works fine in visual studio. In the project, there is no reference to the above given assemblies(not even the razor but i am using razor engine only).
So why should i add the above files to the bin directory if my project is running without referencing them in the first place
Those assemblies need to be available somehow. If you have installed ASP.NET MVC 3 then they will be registered in the GAC (see here: http://weblogs.asp.net/scottgu/archive/2011/01/18/running-an-asp-net-mvc-3-app-on-a-web-server-that-doesn-t-have-asp-net-mvc-3-installed.aspx).
If not (e.g. if you are using shared hosting which doesn't have ASP.NET MVC 3 installed), then you will need to bin deploy them as described here: http://haacked.com/archive/2011/05/25/bin-deploying-asp-net-mvc-3.aspx
Refer to the second link to actually do the deployment. The first link is more for background reading.

asp.net Mvc3 Razor : is there a way to compile a single view from vs2010 ide

I know it's possible to compile all views on building the project... but I was wondering if there is a way to compile a single view on demand in the VS2010.
That way, when you change a view, you could compile this one view (instead of letting VS2010 build all views).
As far as I know Microsoft did not yet add support for precompiling Razor views. But the team released a VS2010 extensions that should allow this. You may check out the following blog post from David Ebbo:
Precompile your MVC Razor views using RazorGenerator
Here is another appreach:
Compile your asp.net mvc Razor views into a seperate dll

Is it possible to use LinqPad with an ASP.NET Website (Rather than a Web Application)?

I'm very interested in testing out LinqPad with our Entity Framework 4.0 based websites, but when I load up LinqPad it wants me to attach it to an assembly (dll or exe). The ASP.NET applications we are building are using the 'Website' template (App_Code folder, etc.) that is not deployed as a compiled DLL. I realize that if the project type were 'ASP.NET Web Application' I would have access to the DLL, but unfortunately this is out of my control.
Is it in any way possible for me to use LinqPad in my situation?
I suggest moving Entity classes to a separate assembly. This will not just solve your problem, but also is the right thing to do from design standpoint.
Also, you could convert your web site to web application.
[Update]
If you cannot split entities to a separate assembly, and if converting to web application is not feasible, you could try extracting compiled dll from web site.
When your site is built the dll will be located at path like this (depends on your platform):
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\website1

Resources