Toggle to switch "copy to output: always" for all .cshtml files - asp.net

I've got a fubu mvc application that only works on local iis if my view files (.cshtml) are copy to output and set as resources (via the properties menu).
However, for them to be picked up on windows azure they need to be set as "copy to output: always" but not set as resources.
Is it possible to change this setting in code or powershell? So I can flip a switch before pushing to azure, then flip it back after?

I'm late to the party but the answer to your question is that .cshtml-files must be set as Build Action: Content under Properties. This is the default build action for MVC-views.
Copy to output directory should be set to Do not copy

Related

ASP Site - Updating Dlls on Change

When I make a change to the a aspx.cs page in my website and then build I notice that none of the dlls in the Bin folder are updated, the only dlls I can see in there are the references the web app uses. I want to bring across this one change rather than redeploy the whole site so where are the changes being saved?
I've tried various things like build solution, rebuild solution, build website, rebuild web site.
Is it possible my dll is being sent elsewhere? How would I go about finding out where?
In Solution Explorer, on root project node, right-click and select Properties. Click on the "Build" tab and look under "Output" section. Here you will see the actual output path and can change it to your bin folder.
In Solution Explorer, on root project node, right-click and try to Clean solution and then again build whole solution.

eclipse and websphere 8.0 - cannot change the context root

I have the IBM plugin for eclipse that allows me to develop on websphere 8.0 servers. I'm using eclipse (Juno Build).
Normally, in the project explorer, I can change the context root of an application simply by right-clicking >> properties >> Web Project Settings >> and setting the context root right there. I can literally set that context root to anything, and it doesn't change anything about it. When I check the admin console, it displays as being 'AppName', rather than anything I've set in the web project settings. That and I'm unable to change it right there in the console, since the only button I can click is "cancel". All the text fields are there for me to change it, but there's no save button anywhere...
Has anyone else had this issue? What did you do to fix it, if at all?
There are 2 places you can set a Context Root in WebSphere.
The first is in the module definition inside the application.xml file of the EAR (That file is not mandatory in WAS 8 but it is possible to use it)
The second is in the ibm-web-ext.xml file inside the WAR.
Is it important to keep in mind the application.xml settings override the ibm-web-ext.xml settings.
When you set the context root in the UI it is setting the ibm-web-ext.xml file, if you got another definition in application.xml you will see no change, as you experiencing.
My suggestion is, if you are using application.xml always set the context root there.

Publish only edited page in asp.net

Whenever I update a small part of my website I have to upload whole website again.
If i upload only edited part it throw me exception.
The way I upload my website:
For example if I have 4 pages (home, register, about me, contact me) and if I update home.aspx, I publish whole website in a local address, and then I compress it with zip format and upload it manually.
Is it possible to publish only updated part?
It is not possible to publish only a part of website, but what you can do is to choose Single-File Assembly build option ,by this you can get single assembly for your page.so intead of updating whole application you can update only the pages you change
read more
What I always do when publish ASP.Net Webform project, I complate it with two steps. Maybe this way suitable for you.
When you use publishing tool on visual studio by selecting Build menu -> Publish, you can choose "File System" as "Publish Method", type your "Target Location", and select "Replace matching files with local copies". It mean the project will publish modified files only.
After publishing have done, Open defined "Target Location" using windows explore and sort by "Modified Date" and just copy newer modified files for each directory recursively to your server.
If you build the website pages into dll. You can not published only the aspx. there are many other dll and compiled files in bin folder, we don't know which matches which aspx.
If you only edited the "view", i mean, the html and markup part of <%%> code, and no code behind (.aspx.cs) change, you can published only this aspx. But remember to set website as updatable in the publish dialog.
I suggest you to compile the aspx into one dll. according to #Buzz 's answer. Then, your aspx files would be only an empty file. All you need to do is upload only one dll to the bin folder.

Published project files ignored

I've been trying to publish my Visual Studio 2010 project. I do this by accessing a hard drive which corresponds to a URL, so X:\Options\Forms\HD\ corresponds to /HD. Yet when I go to the URL, it says I don't have a default.aspx page. Yet when I look in the corresponding file directory the default.aspx page is right there. Why is the browser ignoring it? Another issue I have is that not all of the files are getting published when I select the option in Visual Studio; many are left behind including my default.aspx.vb file.
To make sure files get published, make sure that they have the correct Build Action set (check the Properties window for the file). Especially, if it is set to None or if the files are not part of the solution/project they won't get published. The "Content" build action is a good choice for any file that just needs to be published.
Extra tip: for files that VS doesn't know the default build action is None. You can however configure VS to use whatever build action you want.
I've written about it here: http://blog.andreloker.de/post/2010/07/02/Visual-Studio-default-build-action-for-non-default-file-types.aspx
Also, I've created a simple tool that generates the necessary configuration file: http://tools.andreloker.de/dbag

Why doesnt my img show up in ASP.NET

I created a C# web project with MSVS 9 and thats all i know about my configurations.
In my browser i can access any aspx files i have in my project. However when i use http://localhost:3288/img/test.png i see nothing. The working directory is ./root, the png file is in ./root/img/test.png How do i have ASP.NET display my images and everything else in the folder? (and subfolders).
Is the .png included in the solution?
When you hit the "play" button your essentially starting up a new website ( localhost:2383 ) so if its not in the solution it won't be copied over to the new, temporary, website that the debugger attaches too.
If this is the problem a quick fix is to hit the "Show all Files" button on the top of your solution explorer, this will show all the files in that folder on your hard drive. Then right click on the .png you want to include and hit "Include in Project".
Based on your comment your only solution is to actually create an IIS site for your solution with the root dir the same as your web project. Then in the project properties you'll have to tell the debugger to attach to your local IIS instead of visual studios. Not sure the exact click path, right click on your project and go to properties, look for debugging options.
Give a look to the ASP Image control , you can specify paths starting in your app root (~):
<asp:Image id="Image1" runat="server"
ImageUrl="~/Images/image1.png"/>
Or you can use relative paths to the page that are displayed.
Check this article about ASP .NET Website Paths.

Resources