I am introducing ASP.NET MVC to a new team and one of the questions that comes up often is "Is there a designer view"
Even if it's not for layout is there an IN visual studio design view for ASP.NET MVC3 using the razor view engine.
No, there is no designer. It would likely be difficult for a designer to even know what is meant by Razor code in many cases.
It's really not so difficult to just use your web browser as a viewer. You can make changes to the HTML without having to recompile, just make the change, save, and refresh your browser.
EDIT (8/2/2013)
Since this answer was originally written, Microsoft has released Visual Studio 2012 which includes a feature called Page Inspector, which while not a true "designer" in the way that the question was written, it does give a much nicer semi-live preview mode. This has been improved in Visual Studio 2013 (which was RTM'd today, 10/17/13).
I use a web browser window and set the url my localhost in place of the designer.
view > "other windows" > "web browser". I then split the windows vertically or horizontaly.
I was able to work using the following trick:
change the razor file's extension to .html
Open the document
with the document open, change file extension back to .cshtml
Congratulations, you now have a designer's view of the razor file. If you need razor intellisense, close and re-open it.
No, in general you should try and steer clear from visual designers. The combination of HTML/CSS/Javascript is something that just cannot be done well with visual designers and the short term pain of learning these manually will be well worth it. Once you know these well you will be coding in a cleaner and quicker way. I often use Expression Web to do initial layouts before copying it to Visual Studio.
I know I am late to the party, but..
You can trick the IDE as mentioned above, but if you are building applications in MVC, you should be comfortable in code view. It is more productive and most of the responsive design and css implementation can give you false results in design view. Designer is useful in WebForms. But with the Browser Link feature in Visual Studio 2013, there is no longer any reason to trick your IDE, you can have one-to-many browsers open and get live updates back and forth from browser to visual studio. Can't beat that! The browser is where it's at!
Browser Link!
Install the following and you will be golden!
Microsoft Visual Studio 2013 Update 3
Web Essentials (Dependent on VS Update 3)
I think they are working on that as a feature for Expression Blend 5 Developer Preview .
They clearly recognise the issue of designing JS in the designer so I suspect they realise the same applies to some designers working on MVC applications.
I was told by someone from Microsoft "I think in Blend for HTML, using interactive mode, you would probably be just fine with designing MVC or MVVM patterns"
Also check out Visual Studio Page Inspector it looks like it will do what is needed
In Visual Studio 2013 added browser link this allows two way communication between browser and Visual Studio. It means you can refresh browser when you change code and instantly see how it looks. Also you can change Css in the browser and have it saved in Visual Studio
There is workaround it is mentioned here http://www.codeproject.com/KB/aspnet/EnablingDesignerSupport.aspx
Related
I am building a project using ASP.NET MVC CORE. I want to be able to run my project and see the impact of my code changes in real time, i.e., I see the changes on the browser as I tweak things in Visual Studio 2022.
What extension do I need for this?
I realise this question has probably been asked before but I haven't been able to find the answer here or through Google.
I discovered the answer to this question this morning. I only need to hit F5 in the browser and the code changes will show.
I just installed VS 2017 and am opening an MVC 5 project created in VS 2015. The application runs fine, but I am experiencing reduced interactivity between my MVC Razor view code and the 2017 IDE.
Here's is the context menu when I right-click on an HTML helper method in VS 2015:
However, I only see this in 2017:
Also notice the lack of syntax color-coding in the 2017 verison. It's like it's not recognizing Razor syntax at all.
I did not do any special solution/project upgrades. I just opened the solution in 2017 and expected it to prompt me to upgrade any files that needed upgrading.
So it turns out that the component installation for VS 2017 is modular in that you have to install exactly what you need. This is different from 2015 (at least as far as I recall) where all components are included with the installation.
I have a tendency not to read entire pages and just focus on what seems like the "most comprehensive" option. In my case, I selected only Universal Windows Platform development (doesn't that just sound like everything you'd need?). If I bothered to look at all the components, I would have seen ASP.NET and web development.
So, after modifying my installation, I am now seeing all the Razor syntax in my views.
Repair your Visual Studio installation. This happened to me as well.
Go to Tools Options and customize menus and ribbons
also have a look: https://msdn.microsoft.com/en-us/library/wdee4yb6.aspx
and or: https://msdn.microsoft.com/en-us/library/wdee4yb6(v=vs.110).aspx
try reset the existing window layout or menus and options.
or repair your VS
I have quite an odd issue in VS 2015 CE. I'm working on a ASP MVC site and when I I try to access Model properties using Razor in view inside a method a visual studio immediately closes the intellisense window which shows the available properties.
Works perfectly:
#Model.Shared.UserName
Doesn't work
#Html.Raw(Model.Shared.UserName)
When I'm typing the "Model." inside a method, Visual studio keeps closing up the suggestion window. This is becoming really annoying. Has anyone experienced something similar?
The window I'm referring to:
A workaround that I've managed to satisfy myself with after half a year is to use ReSharper which amazingly fixed this issue as well. It's not exactly solution to why the Visual studio is acting this way, but there is probably little left to do.
We are attempting to add MVC to an old, large, legacy webforms app. (The intent is to gradually re-implement portions of the app using MVC until the old app is gone).
Setting it up has gone smoothly. We have an MVC Area, and I created a controller which is accessible when running the app, by means on directly typing the url.
But whenever we "Add > Controller" or "Add > View"... Visual Studio hangs for around 10 minutes "Not Responding".
Clearly there is some bug in visual studio interacting with some quirk in our legacy project.
Googling, I have so far found only a few similar cases that are old & do not seem applicable.
Not sure where to begin resolving this.
UPDATE:
For what it is worth, we have converted the original VB webforms project to C#. I then added MVC Nuget package and and MVC area. Visual studio no longer seems to hang when adding controllers. So this might be a VB specific thing. Or maybe some windows update to visual studio fixed this in the interim since i posted this. Not sure.
The problem is still present in Visual Studio 2015 Update 1.
As a workaround, instead of selecting "Add View" you can select "New Item" and choose a page template from Web/MVC instead.
It is still in Visual Studio 2017; It takes time and you can restart making Controller/View or you can wait sometimes
this seems like bugs from visual studio,
you can copy other controller and paste it then rename namespace.
for temporary until visual studio is fixed.
I'm having the same issue. This should work. I'm selecting "Add Controller" from the context menu. It just spins saying Visual Studio not responding. This is with Visual Studio 2015.
In my case this situation arises when adding view to the controller and visual studio 2015 hangs indefinitely. However it creates the view file in the directory but not shown in solution explorer. I have manually copy pasted the file from directory to solution explorer and everything worked well.
Check if the below blog could help resolve your issue
http://digioz.blogspot.co.uk/2013/06/visual-studio-2012-freezes-or-crashes.html
I am doing an MVC project... am very new to MVC... something very strange is happening...
When I drop a control from the toolbox to the design page visual studio closes.. I have no clue why this happens.. am totally perplexed...I tried searching for possible solution in the net...nothing showed up...:(
Unless I've totally missed the boat, you shouldn't be able to drag-and-drop any control from the toolbox to an MVC view. At least in MVC 1.0, views and user controls do not implement code-behind by default, but, more importantly, the designer code file that gets modified in WinForms .ASPXs and .ASCXs is not created when the view is created. In MVC, controls are added to views using code-based HTML helpers or the actual HTML code. The fact that the default Visual Studio behavior when executing a drag-and-drop with a toolbox control is to modify the form's designer file could be causing the immediate exit, since the file doesn't exist.
P.S. Don't bother trying to create it...the framework isn't built to implement or support it and it would probably just slow you down, anyway.
Try to start Visual Studio in safemode via
cd C:\Program files\Microsoft Visual Studio 9.0\Common7\IDE
devenv.exe /safemode /log
If this works then one of the installed add ons is responsible for the crash. It often helps in my environment.
Also you may try cleaning up the project.
Run
c:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe yoursolution.sln /t:Clean
Might help if something got screwed in your project.