Why my changes on partial views are not updated until rebuild? - asp.net-core-mvc

Using .Net Core, and Vidsual Studio Community 2015, on an MVC application, if while debugging I make a simple change on my view's HTML (let's say, add an H1) and hit F5 on the browser, I see the changes reflected.
But, if I make a simple change on a partial view's HTML inside that view, and hit F5 on the browser, nothing happens.
I have to start debugging again to see the changes reflected. Is really annoying and a huge time waster.
Any idea? Am I the only one?

Which version of .NET Core MVC are you using? Currently I'm targeting 1.0.1 ( with new csproj ) and it works fine. Did you use IISExpress or cmd boostrap to run your application? Did you try to create a new proj and do that same on that?

I solved it. Weird, in my opinion, but I was including the view with the full path:
#Html.Partial("../Shared/_PartialViewName", Model)
I changed to:
#Html.Partial("_PartialViewName", Model)
And now everything works fine. Shame on you .Net Core. Shame on you.

Related

Problem with "Edit and Continue" in a ASP.NET core mixed Razor Pages and MVC app

I'm trying to update an old webpage that I had developed using MVC. Now I'm adding Razor Pages, but then Edit and Continue won't work anymore.
I can isolate/reproduce the problem in a minimal context. It seems to occur when there are files both in Pages and in Views, e.g. _ViewStart.cshtml.
Here is how to reproduce:
Create an ASP.NET Core Web App, .NET 5.0, No Authentication, no HTTPs, no Docker, enable Razor runtime compilation
Place a breakpoint in IndexModel constructor
Run App
When hitting the breakpoint, edit the code (just add a semicolon in the ctor), continue: code will compile and continue
Add new folder "Views"
Copy _ViewStart.cshtml from Pages to Views
Run App again
When hitting the breakpoint, edit the code (just add a semicolon in the ctor), continue, get message: "Edits were made to the code which cannot be applied while debugging"
I could probably work around the issue, but I'd rather try to understand why this happens.
This also happens when I add the Identity package and try to customize the pages, in which case I also need a double _ViewStart.cshtml...
Any ideas?

_ViewStart and _Layout.cshtml files are automatically created in ASP.NET MVC 5 (annoying)

I am having a Weird and annoying problem. In my ASP.NET MVC 5 project, time to time, I see that _ViewStart file and Shared/_Layout.cshtml files are created automatically even though I did not want. So, I deleted those files but these files are getting created time to time by itself. That cause a great problem because, sometimes, if I dont notice that these files are created, I can accidentally publish the website and then, after publish, I notice that all pages are being wrapped by the auto created _Layout.cshtml file. Is it a smart helping feature of Visual Studio 2013 ? Cant we stop this ?
Emran!
I am not sure that you still need the answer but today I have also met similar problem. By some unknown reason file "Shared/_Layout.cshtml" was automatically added to my Project.
I was realy wondering why could it happen and I found which actions should be performed to make this file be created.
I have added new View to my Project and have used for it standard VS resources:
Right mouse click on Views folder.
Add -> Veiw...
Inside window for adding view I have checked "Use a layout page" and have left field below empty.
Press Add
My VS was thinking a lot and suddenly created new view and also... "Shared/_Layout.cshtml" and "Shared/_ViewStart.cshtml" files!! I do not think that this option might be switched off because it is logically to create layout page when it has been missed.
Hope this info is helpful for you and for anybody else :)

How to use Xcode Utility view?

Sorry for such a basic question.
After using MS Visual Studio for 15 years, I recently moved to Apple and its Xcode. So I am really newbie in this new tool. I can work with some very basic parts of utilities as Referencing outlets or such stuff, but there are a lot of other stuff there that I had never seen in Visual Studio (as file owner, accessibility reference, ...)
I am looking for a good tutorial on that. Any one knows any? Any suggestions will be appreciated.
Apple has very helpful documentation about their technologies: OSX and iOS
The best place to start using Xcode is Xcode 4 User Guide and Xcode Quick Start Guide
This is something like Properties menu in VS. the only difference is that you can simply change to Assistant editor and hold control+drag from each one directly to your code.
Remember this is based on MVC ( Model= data, View= what you see and Controller)
In fact view and model are almost separated and controller is the connector between them:
this may help in the picture above: everything is counted based on Controller: OUT-let can remind you OUT of controller: I mean commands from controller to something. and sender means what sends messages TO the controller. These will make codes just like delegate coding in Visual Studio when you drag and drop an object to the window and double click on them. The (id)sender is counterpart of (void)sender in VS.
watch the Stanford iOS class on iTunesU. It is very good and if you know programming it will be very fast. Make sure you watch the fall 2011 version, it is about iOS5 and xcode4.

ASP.NET MVC Add View Dialog closing

Recently a large project I work on started having a problem with the Add View dialog. When clicking the Add Strongly-typed View checkbox, the spinner comes up the first time for about a second or two, and then the entire dialog just closes and disappears. If I open the dialog and click the button again, it just closes again quickly.
The project is using ASP.NET MVC 2, I have installed VS2010 SP1 and this problem occurs with or without the MVC3 tools update installed. It only happens with this project, and I have replicated the problem on 2 different development machines. If I create a new MVC2 or MVC3 project, this does not happen at all, nor do any other small to medium sized projects I have.
I can of create a regular view and change it to strongly typed by myself, so there is a workaround, but this is still pretty annoying. Any ideas what could be causing this or how to fix it?
Do you use version control? Make sure all the assemblies that your project depends on (i.e. referenced by the project itself or by its referenced assemblies) are in sync. I've just run into this (both "Add View" and "Add Controller" problems) after updating a bunch of projects from SVN and rebuilding some. The issue was fixed after I rebuilt several libraries that my MVC project depends on.
I had the same problem, and I could not open the Add->Controller dialog either as described here: Add Controller after recent tools update fails with dependency error. In my case, I had added models to my domain, but I had forgotten to add contexts for these new models; things like
public DbSet<Region> Regions { get; set; }
I had no error at compile time, and I was not using these models yes in the solution, so there was no error at run time either. I guess the problem can be anywhere though.

mvc html.serialize to store model in view

Can anyone tell me what happened to the Html.Serialize function mentioned in the url below.
It's not recognized when I try and use it in a MVC2 web app within Visual Studio 2010.
http://weblogs.asp.net/shijuvarghese/archive/2010/03/06/persisting-model-state-in-asp-net-mvc-using-html-serialize.aspx
EDIT - I'm using visual studio 2010 which comes with mvc2 'built in' when i try and use Html.serialize on a view or partial view it's not appearing in intellisense. Am i missing a reference or something?
It hasn't gone anywhere. It is right there, wherever you are able to use the html extensions. Eg, Views, PartialViews.
For example:
<%= Html.Serialize("wizardData", Model)%>
Are you trying to use it in a controller? To use it as shown in the article you quote, you need to use it in a view.
You see, we really don't know because you haven't given us any detail to work with. Show us some code, and we will move your earth. Well, try to anyway.
I see you are new, so when asking questions, try to give as much detail as possible. You can edit your post, just mark out what you have done. The more context we get, the more we can help.
I found out why! I was having similar problems too.
You need to download ASP.NET 2 Futures and use the DLLs provided there instead of the usual Mvc DLL.
It is implemented in SerializationExtensions class.
It's in the MVCFutures assembly and not part of the out the box MVC framework. You will need to add the package via nuget or manual download and then add a using/imports statement to Microsoft.Web.Mvc before you can use it in your view.

Resources