ASP.NET MVC website viewmodel not updating after publish, but works fine running in release - visual-studio

I made some updates to my ASP.NET MVC website, including a change to this ViewModel. It works 100% fine running IIS Express in Visual Studio after a build in Release. However, after publishing... it is not updating this specific ViewModel for whatever reason.
That property is 100% there. I have no doubt this should be working. Something is going on with either the publish or the IIS server itself. I think it is the publish, because I have been deploying the last build .zip file and it works fine. Only the recent publishes with this new update are acting up. It's driving me crazy.
Is there anything I can do to make sure this is publishing fresh or building fresh?
EDIT: I was able to manually copy my project's .dll file to my web server and it worked. Why would the publish not update my .dll file? I am publishing to a fresh .zip file each time.

If you change only the views, CSS, javascript, you could xcopy command to only the modified files but if you change the source code you need to recompile the application and redeploy it.if you change your source code you only need to xcopy your particular dll. No need to redeploy whole application unless you didn't split your application in multiple logical layers.
You can refer the below link for more detail:
how to make changes on a deployed Asp.net MVC website

Related

IIS (AWS) Deployment Issues

I am having some problems deploying an app I created to IIS on Amazon AWS. I have basically taken a sabbatical from development and haven't deployed an app in over a year.
The app has been transferred across fine and runs to the point of causing errors and displaying that frameworks are missing etc. I solved this in the past by:
Changing what version of .NET was being used on the server
Including all DLLs when the programme actually transferred (not what it does by default)
For the life of me, I cannot remember how to include all DLLs when deploying the programme so those can be relied on instead of the system's frameworks. Can someone please remind me?
You can do Right Click on Project and select Add Deployable Dependencies from the context menu
As of MVC4, all necessary assemblies to run an MVC application are
automatically added to the bin directory, and any MVC4 application is
bin-deployable (means you can run it in a server without explicitly
installing MVC) . For this reason, the Include Deployable Assemblies
dialog has been removed from Visual Studio 2012
More here: https://stackoverflow.com/a/10441585/1241400
Are you by any chance talking about Bin Deploying MVC? It's kind of a pain to do, considering you need to remember to make sure those dependencies are in your bin folder any time you either move the application around, put it on a new server, etc.
What errors is your displaying? I think you'd probably be better off resolving those, if possible. Windows has gotten much friendlier with installing updates in the past few years.

Web.config Vandalized Mystically During Azure Deployment

I know this is super weird, so to make you believe me and help me, I provide lots of evidence here.
Problem: the web.config file under site/1/views has been changed during Azure Deployment.
Facts:
The file exist in .cspkg package, not the case here
No other web.config been changed, not the root one, not the one in site 2,3,4.., not in area, not in any other places. The whole solution has 10+ web.config files, but only this one, the one under Views of site/1 has been changed.
File is not been replaced, is been edited, only change is 2.0.0.0 -> 1.0.0.0 and
4.0.0.0 to 3.0.0.0, which is a targeted vandalize, I have to say. Nothing else changed, my own namespaces defined still there.
Tried:
Remote Desktop to the Azure Instance, edit the file, the site works, and it won't change back even after reboot (except the reboot at Azure interface which whole package just reloaded)
Repackage and redeploy, twice, no use.
Changes I made from last deployment, which was a success one
Install Visual Studio 2012 Ultimate trial today
Upgrade the whole solution from MVC3 to MVC4, Azure SDK from 1.0 to 1.7
Change all project from framework 4.0 to 4.5, found Azure cannot support 4.5, then change back to 4.0
finally built and packaged
Whole package works well before under Visual Studio 2010
Whole solution works well in local as well
Pictures
pic1
Original web.config file under site(1) Views folder
pic2
It's in .cspkg package.
pic3
Check again from remote desktop
Final words
I know there's a solution is make site(1) empty, a dummy site, so whatever been changed will not matter. Or just load my backup and back to VS2010. But I do really really like to know how it got changed, and how to avoid it, thanks.

Visual Studio 2010 gets stuck with solution with MVC3 Razor and Azure

I've a solution with several .dll projects, an Asp.NET MVC3 Razor project and an Cloud project.
If I try to compile the solution with the Cloud project loaded, VS2010 gets stuck in "Buil started".
I have to forcefully close VS2010 killing the process and restart. Then the compiling works good once, the next time it will get stuck again.
If I unload the project and set the mvc project as start-up, everything works (but azure of course).
What could be the problem?
Cheers.
Was it by any chance an ASP.NET MVC project to which you added a CloudService project later on or did you start off with a CloudService from the very beginning?
I was in the former situation and I had no end of problems, like not being able to open property pages or deploying the application. It's not quite your issue, but the following article might help:
http://tomkrueger.wordpress.com/2010/07/27/azure-deployment-issue-after-upgrading-to-visual-studio-2010-and-net-4-0/
As I say, my problems started because I actually added an Azure project to an existing ASP.NET MVC solution and there were some unnecessary settings left over in the web.csproj file.
All I had to do was open web.csproj in notepad and remove all occurrences of the <PlatformTarget> element.
My MVC prjoject was x86 and of course Azure works on x64 only. Even though I had the platform target set up as AnyCPU somehow Azure couldn't quite get along with it.
Maybe cleaning up your project files helps as well.

How to precompile ASP.NET 4.0 to a Single DLL with VS 2010

I recently upgraded from VS 2003 where I was working on a ASP.NET 2.0 website to VS 2010 where I have migrated to ASP.NET 4.0. So far it has been a big headache to get my site compiling with the new version. One problem was that my aspx.cs pages could not find the shared code libraries in my project. I solved this by moving my shared code to the App_Code folder (if there's a different/better way to do it please let me know).
Another issue that I am finding confusing is with pre-compilation. With VS 2003 I could click the build project button and it would precompile my site into a myweb.dll and myweb.pdb files. Now I'm having trouble doing the same in VS 2010. When I build the site in VS 2010 the dll is not created. I did manage to find an option to "Publish" the site which takes forever (like 2 minutes) and involves duplicating the site to another folder. This would have been acceptable but instead of making the single DLL file, it makes a bunch of files: App_code.compiled, app_code.dll, App_code.pdb, App_global.asax.compiled, App_global.asax.dll, App_global.asax.pdb, App_Web_lrpcway1.dll, App_Web_lrpcway1.compiled, App_Web_lrpcway1.pdb.
The application works - I can deploy it with all these files. However, I'd really like someone to explain what are the extra files and if there is a better way how to do it.
Thanks
This is the difference between a website and a web application.
You can convert your website to a web application to have it
behave more like you are used to.
The files in appCode are compiled when required to run and thus
does not provide dll.s in the bin/debug folder, but they should
be created when the application actually runs (but it is not
put in the same location).
Here is a nice write up about it Link
You can use the ASP.NET Merge Tool to combine all of the little DLLs into one big one.
http://msdn.microsoft.com/en-us/library/bb397866.aspx

Problem after publishing web application from VS 2010

Whenever I publish my MVC web application in VS 2010 via the One-click publish feature (I'm not doing any web.config transforms or anything fancy - yet!). The next time I come to build the app I get the following error:
It is an error to use a section registered as allowDefinition='MachineToApplication'
beyond application level. This error can be caused by a virtual directory not being
configured as an application in IIS. in ...MyWebApp\obj\release\package\packagetmp
\web.config
A new copy of the web.config file is indeed created by VS2010 below the ...MyWebApp\obj\ folder so I deleted the whole obj folder and I was then able to build again.
But I shouldn't have to do that each time I publish - I must have something configured incorrectly - can anyone help please.
Thanks.
This is unfortunately a known issue with Publishing a web application to the file system. This still affects the release version (RTM) of Visual Studio 2010. It's not limited to the Beta or RC versions.
This problem "bit" me also, and I too was having to manually delete the Debug and Release folders inside the obj folder within my web site solution folder.
The real answer for an automated "workaround" can be found in this answer to the other Stack Overflow question:
Why do I randomly get a “error to use section registered as allowDefinition='MachineToApplication'” when building an MVC project?
In a nutshell, you need to delete the web.config files from either the Debug or Release folders (or both!), and that's achieved with a pre-build command (configured in the Build Events tab of the Project Properties page of your solution):
del "$(ProjectDir)\obj\Debug\Package\PackageTmp\web.config"
del "$(ProjectDir)\obj\Release\Package\PackageTmp\web.config"
Personally, I delete the entire obj folder since all those files are re-created with each build anyway.
I have just found a work around for this that has worked for me, open the .csproj for your web project and change the node under the Project\PropertyGroup node to this:
from this:
<MvcBuildViews>true</MvcBuildViews>
to this:
<MvcBuildViews>false</MvcBuildViews>
This has worked for me, hopefully it will work for you also.

Resources