mvc which files are needed for deployment? - asp.net

I've been working with webforms and recently started to work with mvc. With webforms, when we use to push to the qa/prod server, we alway copied over the files. leaving behind the .cs files, so just the .aspx, bin folder, along with associated js/css files would go.
with mvc, if we are copying the directory over from our pc (where we develop), what files are needed, do we need the .cshtml files for example? I just want to avoid having to push all the files if they are not needed.

They are definitely not all required. What you are going to want to do is setup a way to publish, this ranges from doing a "bin deploy" to feeding in ftp settings and using a "single click deploy" approach.
What it all boils down to though is this. You will need
A bin folder with every relevant .dll
A content folder with relevant images and css files
A script folder with relevant .js scripts
A views folder with nested folders for views with relevant .cshtml files
A .webconfig file in the views folder and also one at the very root
The packages.xml file at the very root
The global.asax file with markup pointing to the application starting in global.asax.cs
What this excludes is every single .cs file. These will all be composed into your projects .dll. So if you are developing FunWebApp, then all your c# will be rolled into FunWebApp.dll in your bin folder.

Use the Visual studio "Publish" option available on your UI Project. This will generates all the required files you neeeds includes, bin folder, Views folder(which will have the .cshtml files),Content folder,Script folder, Config file(web.config) etc.
Right click on your project and select "Publish". You will be shown a wizard where you can define what kind of publish you want. You have different options like FTP, File system etc.
You will not see the Controllers folder / Other class files because code inside that folder is compiled to your assembly which is in the Bin folder

Related

keeping the compiled project inside one common directory inside wwwroot folder

I don't know if you guys have face the same problem as mine.
When I place my compiled web app inside wwwroot, everything works fine.
Suppose my compiled web app has directories
bin, view (contains aspx pages and master page file) then web config and packages.config files.
Now if I place these files and folders just inside my wwwroot directory C:\inetpub\wwwroot everything works fine. I can browse my web application.
But when I put these files and folders inside one common directory say Project such that now the file path become C:\inetpub\wwwroot\Project
Now I get issues like
Parser Error Message: Could not load type 'Project.view.AdminMaster'. error with pre compiled classes. Why is it so ?

Howto add and link to existing WebSite project from ASP.NET project

I have an existing Website project; its just one .html and a bunch of .js files (all client-side stuff). This project only has a .sln file, no *.*proj files. It's directory structure is basically:
WEB_PROJECT_ROOT/apps/foo/index.html
WEB_PROJECT_ROOT/lib/*.js
Now I'm working on a new ASP.NET Forms Application, and I need to link to index.html page above, but I'd like to keep it as a separate project (and not just copy it into the new ASP.NET project). It's structure is basically:
APP_PROJECT_ROOT/Pages/*.aspx
I've done Add -> Existing Project and chosen the .sln from above, and it shows up in the ASP.NET solution, but I can't figure out how to link to index.html because it's outside of the ASP.NET project's ~/ directory. Is there are way to symlink to it somehow? Or something else?

How can I view/set build option in file properties

I feel like asking a dumb question, but I just do not see the options I need in Visual Studio 2010 File Properties. The only options I see are: File Name, and Full Path. What I need to set is: Build Action, and Copy To Output Directory.
Question update:
I just found out that File Properties shows the Advanced options for files in class libraries, but not for files from the actual web site. But how do I set the mentioned options to the resource file App_GlobalResources/Contact.resx , which by default does not appear in the published version of the web project?
From ASP.NET Precompilation Overview
Resources (.resx) files:
For .resx files in the App_GlobalResources folders, generates an
assembly or assemblies and a culture structure. For .resx files in the
App_LocalResources folders, copies files as is to the
App_LocalResources folder of the output location.
Assemblies are put in the Bin folder

How can I change any app code class after publishing the website?

I upload the website after publishing it, now I want to change a line of code in a class which resides in app_code folder. After changes I again publish the website and upload the new app_code.dll to replace the old one but its not working. The whole functionality of app_code is not working. Is there anybody to solve my problem? thanx in advance.
The App_Code folder will parse any source files you drop in there, e.g. MyClass.vb or MyClass.cs. If you are compiling classes into a DLL, you want to put the DLL file into the bin folder instead.
If the classes are contained in your project and have their build action set to compile, they will automatically be compiled into the web application's DLL when you run a build, and should update every time you publish the site as a publish automatically builds the project/solution.

Can i put URL rewriting http module in a folder?

I am trying to make a generic URL rewrite methods, and i want it portable so i checked this article: http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx which is very nice.
But i want to put all my classes, http modules in one folder, then i can just paste this folder in any asp.net website and edit the web.config to point to this http module, thats it, without the need to add anything in the APP_Code as this article teaching.
My question is is that possible? any conc or better ideas?
The ASP.NET runtime only looks by default in a limited number of folders for code files that it compiles on the fly -- App_Code (and its subfolders) is one of them. If you place code in an arbitrary folder, it won't be found.
The usual approach for what you describe is to build a DLL, and then drop it into the web site's bin folder. You would then have a separate project in Visual Studio for building the DLL. Using a subfolder in App_Code is another possibility.
You could also put your DLL into the GAC, which would make it accessible to all sites on a server.
You always can to compile that code into an assembly (.dll), place it inside your /bin folder and to update your web.config file.

Resources