Console App CSHTML Intellisense and Binding? - asp.net-mvc

I have a console app without a project reference to any ASP.NET MVC App. Running Visual Studio 2010.
I created a cshtml file to test some template binding. I am not getting IntelliSense in the cshtml and putting "#model MyDataClass" at the beginning of the page is not getting recognized either.
How can get some View functionality in my console app?
Thanks.

Follow instructions in this blog post - https://blogs.msdn.microsoft.com/webdev/2011/01/20/how-to-get-razor-intellisense-for-model-in-a-class-library-project/
Also, add references to System.Web.Razor.dll and System.Web.WebPages.Razor.dll

Try using RazorEngine it allows you to use Razor templating in Console applications.

Related

Visual Studio 2015 - Debug ASP.NET MVC source code immediately on POST

I'm having a problem with the default model binder being slow in my ASP.NET MVC web application on a specific controller. I'm looking to basically debug immediately when I hit the POST and see the ASP.NET MVC source code that is fired first (the model binder, etc.) before my controller's code.
How can I do this? I thought this should be an easy task but Google isn't turning anything up. I'm using Visual Studio 2015.
To debug ASP.NET MVC source code, it was related some debugging options under TOOLS->Options->Debugging.
It also was related to the Microsoft Symbols Server under TOOLS->Options->Debugging->Symbols.
So if you want to debug MVC source code or not, please enable/disable them, view the results.
Reference:
https://weblogs.asp.net/gunnarpeipman/stepping-into-asp-net-mvc-source-code-with-visual-studio-debugger

MVC empty WebSite project based on aspx pages

In Visual Studio we have a two ways that create the web projects.
I create the "WebSite" project, empty-project (like: File -> New -> WebSite... and so on).
After that, when the WebSite created I want to make it to MVC WebSite with ASPX, and not Razor pages.
[I decide create the MVC WebSite not Project Site, with this way, because the Visual Studio doesn't provide us WebSite with MVC template based aspx pages].
After creating some pages I want to create and integrate any Razor page.
Describe for question:
IF I attempt use in the Razor view page - " #model MyWebSite " it does not discovering, and I can't use with the ViewBag property later
Question:
What Can I do ?
What NuGet packeg I need install or what dll recourse I need adding to Bin folder of project.
Yes, you can use Razor with an existing ASP.NET WebSite. Simply open your website using the WebMatrix tool and start adding CSHTML files. One caveat is that if your website is using WebForms controls the WebMatrix tool will not provide any help working with them in existing aspx pages. Additionally, Razor does not support WebForms so you will not be able to add something like to a CSHTML file.

Using ASPX View Engine with MVC 5

Is it possible to use ASPX view engine with MVC 5?
We have a product using MVC 4 on ASPX view engine and we want to migrate to MVC 5, however, when I create a new project in VS 2013, select MVC and try to add a new View, I don't see any option to add a view using ASPX View Engine. Has Microsoft stopped with ASPX View Engine? Is there any way to still use ASPX?
This is what a blog post regarding the release of VS2013 said: "The HTML editor used by Razor files (.cshtml and .vbhtml) as well as normal HTML files has been replaced with entirely new code. Web Forms (.aspx and .ascx) involve significantly more complexity and did not fit into a well-polished release for Visual Studio 2013, so they will be updated in an upcoming product release. " Source:http://blogs.msdn.com/b/webdev/archive/2013/06/27/html-editing-features-in-visual-studio-2013-preview.aspx
It's installed by default. just check out the ViewEngines.Engines collection. Its output are:
System.Web.Mvc.WebFormViewEngine
System.Web.Mvc.RazorViewEngine

Creating a Basic MVC Project with Unit Tests in Visual Studio 2010

I wanted to set up an MVC 2 web application in Visual Studio 2010 using C# as the language. For that, I referred the link: http://msdn.microsoft.com/en-us/library/dd410597.aspx and I created the same. When I ran the application by pressing F5, I got an error in my browser. I have attached the error information below.
Please help me to resolve this.
MVC is different from regular ASP.NET. In MVC you are using the http-address to tell your application which method to fire in which class.
In MVC language methods are called "Actions". And classes are called "Controllers" (ruffly speaking).
If you want the first view to show, you will have to tell the class "HomeController" to perform its method "Index()".
You do this by entering the address: "localhost/Home/Index"
Please read more here:
http://msdn.microsoft.com/en-us/library/dd410269(VS.98).aspx
If your controller is called MapsController with an ViewMaps action as shown in the tutorial then you should navigate to /maps/viewmaps in your browser to execute this action.

ASP.NET MVC (RAZOR) with Expression Web 4, or at least the option to edit the file?

I have been trying to use expression web lately for editing my HTML files etc...
I.e. use visual studio 2010 for coding and expression web for design.
I thought this was what they were meant for?
Anyway the new extension CSHTML (razor) when i try and open it in expression web it automatically opens it in visual studio.
I am not expecting FULL razor support in expression web but at least the possibility of designing the html embedded in the CSHTML file so i can assign CSS and things like that
My way to use Expression Web for CSHTML
you need to add the extension cshtml for open that files in Expression Web for setting that you need to configure Expression Web by Tools > application options > configure editor
you never can found css class in intellisense by any trick for cshtml but can be view the mockup in the design mode.
For what it's worth, I use expression to get the gist of the markup and then copy that HTML/CSS over to Visual Studio into my views. Even if Expression can take care of this, it just doesn't seem to do it very well.

Resources