ASP.NEt MVC edit files on server after deploying - asp.net-mvc

I deployed my site on IIS 7. Can I edit c# files after deploying? In my sites's directory I see only .cstml files (Views), but there are no c# files... How can I do some changes in code without full redeploying? Thank!

Your project is likely a Web Application project. In that project type, the code files are compiled into an assembly (.dll) and that assembly is deployed to the server (the code files are not).
There is another project type called a Web Site, and that one works more like what you are looking for. The code files are deployed with the application, and if you edit any of them, the changes are available immediately (i.e. the code is recompiled).
There are other differences between the two, so please read up on them and decide if it's the right path for you.
Personally, I haven't worked with the Web Site project type in years. Back when it was first released, there was a big outcry against it (so much so that MSFT released an update to restore the Web Application project type), but this is all opinionated and it may work great for you.
There's an MDSN article that details the differences.
The intro paragraph tells you how to create a project of each type in Visual Studio.

Related

Umbraco class library and Web Site

I have a project I was brought onto a few years ago and the original developer is no longer available. We have an Umbraco 6 based website. The solution has two projects, a Web Site and a class library call Umbraco.Extensions. I believe I read some conventional wisdom pertaining to Umbraco at some point where it is recommended to split it up like this but I am looking for more information about this particular style of setup and how it is supposed to work. For example right now I am dealing with a missing assembly issue, and i fixed it by copying a dll from the bin of Extensions to the bin of the Web Site. How is this handled regularly?
it's generally a good idea to keep the projects separated. You should have some kind of automation (maybe a post-build action) to copy the dll of the class library to the bin of the umbraco project. Or maybe rebuild the umbraco project with the correct references, but I dont usually do that.

Best way to reverse deploy an asp.net mvc web application which is not precompiled

I have a Visual Studio 2012, MVC 3, asp.net 4.5, c#, razor web application.
The original application is a 2 project solution with 1 project being the Data layer and the other the web application. When deployed the data layer is represented as a dll.
All Controllers and Views are still in "source" format on the deployed "test" platform, since I have not precompiled the code before deploying.
I have ftped the whole site back to my dev server into a seperate area.
I did try and open this downloaded application as a project and also a website, but got some reference errors.
I do appreciate this is a non ideal state of affairs, and this codebase should be represented as a previous version in source control. However for a number of reason, we need to do this, mainly because we did not do a branch. One lives and learns.
What should be the best way to open this site in Visual Studio to work on it. Obviously I will only have the one project now, as the data project is just another DLL? I will add this fix back to my main codebase, and recommit.
Thanks in advance.

I need to deploy source ASP.NET MVC code on Azure websites, and for it to run

This may be a terribly simple question, but....
I am using MVC3, Razor, C#, ASP.NET4.5/SQL Server 2008 and deploying to Azure Websites & SQL Azure.
I need to copy all of my source code, without compilation, from my web application ie model source, class libraries and views. All additional projects such as Entity Framework DAL projects will remain as a DLL. However I do not wish to have a web application DLL since I need to edit C# code in situ, and have the site run using this code, no doubt using the JIT compiler.
The main reason is because I am doing some integration work and the 3rd party site sends a return url back, and "Localhost" is not very accessible to the outside world, so wish to use my Azure website instead.
So can I copy my web application code as source, and if so is it a matter of copying all the C# files up and removing the web application DLL?
Thanks in advance.
EDIT
Further thoughts. Azure Websites provides a container for the Worker process to operate which hosts the Application DLL which is P-Code which is then dynamically compiled to native code. So I am not sure if one can start with a source C# file like one can with a Razor View.
EDIT2
Or do I need to make the changes on my Local machine and keep republishing to Azure Websites to test the integration? A little long winded...
MVC Sites must be Web Applications, they cannot be on the fly compiled. Sorry, there is no way around this. You must compile your code into a DLL for it to run if you want to use MVC.
The reasons for this are many, but a big one is that the "on the fly" compilation model used by ASP.NET Web Site projects does not use namespaces, and namespaces are very important to the operation of MVC.
Another issue is that MVC depends heavily on static assembly references, which is also not the case in Web Site projects.
In general, ASP.NET Web Site projects are poorly supported, have a lot of issues that make them unsuitable for larger projects, and even more unsuitable for use with more advanced frameworks.

How do teams work on VB ASP.NET MVC sites?

In PHP, you can just log in to the FTP and see all of the files. I notice in VB ASP.NET MVC when I publish a site it doesn't include the controllers or models. Rather, it seems to compile them into DLLs. How can the files be modified with out access to the originals? Would a developer have to publish the files in a separate directory and then the other developer pull them down and open the project in visual studio?
Keep your SourceCode in a Version Control System like SVN /GIT /TFS etc.. Whenever you want to make an update , Get the specific version you want to update and make update to that.
Having a Version control gives you so many advantages
1) Collaborative working. Many members of a team can work on same code base without overwriting conflict
2) Restore to a Previous Version : Something wrong with the current production move ?. Just get the Previous version (Label) which is working fine (and was running in prod) and rollback to that till you fix the issue.
Keeping the Previous versions of code will save a lot of time in a Programmers / Team's life.
This SO question has good points about why we should use version control.
Version control is not only for Teams. Individual developers can keep their code in Version controls and sleep nicely
Btw, Your MVC project's Model classes and Controllers classes are compiled into the DLL files.
I've seen a lot of companies that work with Visual Studio implement Visual Source Safe.
information can be found here http://msdn.microsoft.com/en-us/library/3h0544kx%28v=vs.80%29.aspx
otherwise it's pretty much what Shyju said.
In a professional environment, there is a very clear distinction between editing source code, and deploying to production. You seem to make no distinction.
Usually developers make changes under careful control using a source control system like SVN.
Build & deployment is then done separately by a dedicated team member. Developers do not touch the production servers willy-nilly.
How can the files be modified with out access to the originals?
I don't understand. If you want developers to have full access to the production environment, why not give them full access to the source code as well? In your PHP example this is a given.

How to easily include common code across multiple ASP.NET MVC sites

At work we have about 30 legacy sites which run from a common set of code, currently these sites are in cold fusion. For this common code we have one project, then in IIS we set up a virtual directory to include the common code into each site. This works great, as changes to core logic can be made in one place, and its replicated through all the sites. And as all of our sites are hosted on the same servers, we can also just deploy the common code and all the live sites are updated, we don't need to release every site.
However we are in the process of re-writing our sites and core code into c# and asp.net MVC 3. Its going well, except when we update the core code, we are currently copying the dlls into each site, recompiling, then releasing each site.
This is fine while we only have a couple of sites re-built with the core code, but is going to be very painful when all 30 of our sites have been re-built in .net.
Does anyone have any ideas of how to easily use and delpoy common code without having to copy the dlls to every site?
So far we've tried:
- using a virtual directory of the dlls (doesn't work as site code needs to be re-compiled, and IIS doesn't seem to like it on .net sites anyway)
- deploying our common dlls to the GAC - this is an issue as the third party libraries (eg nHibernate) aren't signed, so can't add them to the GAC too.
Thanks
Saan
The easiest way is to automate your update procedure.
But if you want to rid of copying at all then you can try thing named "codebase".
Here is description of "How the Runtime Locates Assemblies" and details of "Locating the Assembly through Codebases or Probing" http://msdn.microsoft.com/en-us/library/15hyw9x3(v=vs.71).aspx
Interesting.
I also saw in the next .net relase they have http://www.asp.net/vnext/whats-new#_Toc_perf_3 “Sharing Common Assemblies”
This will give us a couple of options to investigate thanks.

Resources