After MVC3 publish, just update the views - asp.net

.NET/MVC3 newbie, so please bear with me!
I've searched for this answer all over but cant find exactly what im looking for, so here it comes...
Lets say that i'm developing an MVC3 app with Visual Web Developer Express and i go about deploying the site using the built in publishing tool.
But now that my site is up and running i find that i need to make a minor adjustment in one of the views. I update the view and save the file, and use my FTP program to upload the new file.
The problem is that MVC3/.NET doesn't seem to refresh/change the view, because it's still using the old version.
Of course I have tried refreshing (in many different browsers even), but it still won't load the new view.
Is this normal behaviour, meaning that i have to publish every time i make some minor adjustments (kinda time consuming)? I really can't imagine that this is the case, so i'm wondering if you could shed some light over this?
Appreciate any replies!
/Mikael

If you upload the view (.cshtml) file and that is the ONLY part of the application that has changed, a refresh will reflect the change - you may have to ctrl+f5 to clear the temp cache. However! If you change ANY of the controller code or action code, or any c# (or vb if thats what you use), then you MUST re-upload the compiled .dll associated with the entire application in order for the changes to be reflected.

Related

Visual Studio 2010: Why I can't change the Full Path of website?

I currently have a solution which recently added a new website to the TFS source control. Due to a mistake during creation, the website physical directory is like below:
Z:\Projects\NewWebSite\NewWebSite
Instead, it should be like below:
Z:\Projects\NewWebSite\
The problem I had was when trying to remove and add the website with the new physical path into the solution. Every time I do so, for some reason it will automatically refers to the first path. If I tried to remove the folder, it will give me an error saying it can't open the path since the folder no longer exists.
My solution is to basically unbind everything and create a new solution from scratch, then re-adding the website to the solution. My worry is that I am just working around the problem, and that it is still present somewhere in TFS, waiting to mess up someone else's solution when they check out.
So, does anyone knows what is causing this, and what is the best way to fix this sort of behavior?
If your solution name is the same as your project name then that is the default structure. When making a new project, start by creating the solution with a unique name and then adding your project to that.
No matter what, you do actually want that structure. Its like that for the purpose of expandability. If you need to add additional projects or maybe separate your operations into different projects (like Data vs Web for instance), the Solution/Project folder setup will accommodate.
In other words, don't fight it. Just make your solution name unique from your Web application name to make it less ugly looking.
TFS doesn't deal with physical locations at all. This is handled by your TFS client, when you map a workspace a physical path. This is not something that TFS deals with.
As such, i'm confused by your comments.

Is it possible to restore the source code (Models, Controllers) of an application, from the files on the website (when Publish has been used)

I have been working on a MVC 3 application on my laptop, which now has crashed. I have uploaded the newest edition of the site through the "Publish" method in VS2010. Is it possible to retrive the source code of the application? Because i cant see the Models or Controllers on the FTP.
Thanks
I have used a decompiler before to get back source code from a compiled website.
It doesnt give you the files all nicely ready to start developing again, it is a bit pain staking going through the decompiler and getting all the code you need out. But it can be done.
I cant remember which one i used, im sure a quick google will give you loads to choose from. I think there might even be one shipped with vs.

updating .net 4 site

Ive just made live a site for a client,
I need to now update it with both design and logic changes.
WHats the best way to do this? Never done it before.
I know I cant just overwrite the amended aspx and aspx.cs files, tried that and although the design changes take effect the coding doesnt.
Any info appreciated
thanks
You need to rebuild the binary in Visual Studio, and upload the DLL to the bin folder. The cs files don't even need to live on the server.

Creating project from existing IIS/ASP.NET website, building stuff

So I'm left maintaining a proprietary codebase from a third-party vendor. The vendor is still sort of around, but support is limp. The site is ASP.NET.
I have made some changes but I am having a really hard time getting IIS to compile these changes in. The bin/ directory has what I believe is a precompiled dll for the core classes. I've changed these but it doesn't recompile. I have tried deleting the dll but then the app refuses to build saying that the Global.asax can't inherit the type anymore, so I don't really know how to rebuild with changes.
I spent all day Saturday setting up a build environment and trying to get a testing thing working. I have just been importing into VS2008 as a web site from the local IIS server. I got it to rebuild the app without changes, but it ignores changes I would place in it.
So I need to make a solution out of this website and/or directory structure so that I can do actual, big, full grown-up rebuilds and make changes to this codebase. Anyone know how I can go about this?
EDIT: A bit more elaboration. I've tried creating a blank project and just Add Existing File... on the whole website directory. This hasn't worked, it stops the import about 10% in.
Keep in mind there are two (actually, three) levels of 'builds' or compiles going on here.
1) The DLLs in the /bin directory should be pre-built, by visual studio or otherwise. The content of .ASPX, ASCX, ASHX, ASAX etc fiels are not included in those.
2) The ASPX, etc files I noted above are then compiled by IIS when the first request comes in (normally; there are ways to change that behavior). That is the source of the error with Global.asax you are seeing; With the DLL(s) gone, the class that Global.asax is supposed to inherit from does not exist.
3) Then there is the just-in-time compilation, which is not relevant for this discussion.
It sounds like you may be missing the source files for the project, or perhaps the web site is not getting properly set up as a project to compile that DLL
Try these links, I suppose this is what you are looking for.
http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/01/20/linking-files-in-visual-studio.aspx
http://support.microsoft.com/kb/306234
Not sure this question is really valid anymore. The source we were working with was rather different than it should have been. Not sure if someone got angry in the past and moved stuff around or what, but grabbing a new copy of the source fixed most of our issues. I am able to build now with an included csproj.
This doesn't really help many others with the same issue I suppose, but if you are getting weird build behavior like this, you might want to start with basics, like making sure that your source checkout is valid.
I am new in asp.net so I am not sure it is a professional way or not.
I have the project without .snl file. I just create a empty web site and then paste the files inside the folder where I created the project.
It worked for me.
I think pasting the files and folder directly by file manager will help you.

Visual Studio 2008 forces me to Rebuild Web Site every time to effect any changes I make

I have been using Visual Studio 2008 for the past 2 years or so. Recently, in 2 particular ASP.NET (with VB.NET) web sites I am forced to do a Rebuild Solution after any change, no matter how minor, even if it's just an HTML change.
In other words, I cannot load the application into the browser and make an HTML change and hit F5 as the change would not be reflected in the browser. Also, if I make a change in the code and try to run the project by clicking F5 the code change would not come into effect. I first have to rebuild, then hit F5, which obviously takes much more time.
Does anyone know why this may be happening? This does not happen with all of my projects but only with 2 in particular.
Thanks in advance,
Tim
Oh the joy of visual studio and web projects!
Things to try:
Clear the VSWebCache (this is usually at %USERPROFILE%\VSWebCache)
Clear Temporary ASP.NET Files (at %WINDIR% %WINDIR%\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files - make sure you keep the security if you delete this top level folder rather than the subfolders)
If you keep your machine on all the time (never a good plan for a development machine), then run iisreset
Super-late, but: http://weblogs.asp.net/scottgu/archive/2006/09/22/Tip_2F00_Trick_3A00_-Optimizing-ASP.NET-2.0-Web-Project-Build-Performance-with-VS-2005.aspx
The meat:
turn off "build web site as part of a solution" in the site's property pages' "build" section.
change the drop-down to "build page" in the same location.
manually build-page to force an update. It even works with my issue, where it won't update any WebMethod()s.
If you see this, let me know if it works!

Resources