is it possible to deploy all codebehind files to a webapplication in addition to all resource files in the bin folder. In such a manner that it will generate the website binary dynamically similarly to how a website works?
We have a asp.net 4.5 vb.net webforms application which we would like to deploy to certain customers in uncompiled mode so custom changes can be made. Is this possible? and if so what is it in either the IIS metadata or the web.config e.t.c. which tells IIS that it should generate the binary itself?
Update typo webforms not winforms :)
A "Web Application" project cannot be deployed like this, however a "Web Site" project can. Have a look at the differences between the two here:
http://msdn.microsoft.com/en-us/library/dd547590(v=vs.110).aspx
Much more information on this subject is contained in this SO question: ASP.NET Web Site or ASP.NET Web Application?
I came across this post while looking information for pros and cons of using this specific way of deployment as I have been doing this myself for quite sometime now. This can be possible if you deploy both your .cs file and .aspx files in the website folder but make sure your .aspx file is directed to .cs file instead of dll file while running. I have been doing this for sometime, where I need some features customization for client and use code file for that specific page only.
aspx file:
<%# page title="" language="C#" masterpagefile="~/School/MasterPage.master" autoeventwireup="true" CodeFile = "academicdashboard.aspx.cs"inherits="School_AcademicDashboard" %>
code file:
public partial class School_AcademicDashboard
Related
I have an ASP.NET WebApplication (not Website) that was written with C#.
I want to publish and deploy this application for more than 50 sites in my server.
I would prefer to make some dlls and put them in GAC of my server so all sites will use dlls from GAC and then I can update all my sites just with replacing some dlls in GAC.
When I publish my application I get a single dll for all .cs files but all .aspx files remain.
I want to merge .aspx files to single assembly too.
Is there any way?or any other idea for my case?
in your web project properties:
package/publish web
check - precompile this application before publishing
advanced - merge all output to a single assembly
When you go to the publish settings there is an option to 'make site updatable', if you untick that all the cs code will be merged into the app_web.dll.
You will still have all the seperate aspx pages, since those define the entry point into the code. To my knowledge the only way to merge those would be to copy/paste all the seperate aspx pages into the default.aspx, and wrap them in <asp:Panel ID="HomePage" Runat="Server" Visible="False"> and then set the right panel visible in the Page_Load depending on the QueryString. You can use URL rewriting to still get nice URLs.
Depending on how many pages you have, and how big they are in code, I would probably not do this myself. But if you find the result of having 1 page outweighs the rest, it is technically possible.
Download IIS Module: http://www.iis.net/downloads/microsoft/url-rewrite
Making rules: http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module
Another option, maybe, is to just host the application on a subdomain and iframe it where it is needed. This might not be possible due to cross-origin problems, depending on your setup, but it would be a 'cleaner' way to work.
Hope this helped.
I'm using MS WebDeploy out of Visual Studio 2010 to deploy a ASP.NET 2.0 web forms site. In my source project I have a master page (admin.master) with a code-behind (admin.master.cs).
Following a successful build and deploy on the target site I have:
\bin\myapp.dll
\admin\admin.master
But no admin.master.cs
However I'm not expecting this as I thought the code-behind would now be in the myapp.dll?
When I fire up the site I get the following error:
The file '/admin/admin.master.cs' does not exist.
Line 1: <%# Master Language="C#" AutoEventWireup="true" CodeFile="admin.master.cs" Inherits="admin" %>
Any ideas what is wrong here?
Many thanks,
Sam
Is this a website or web application?
CodeFile="admin.master.cs" would indicate that it's a website, and in that case you would need to include the code behind files.
Seems odd that when you deploy it builds the dll's and removes the code behind files though.
To deploy a website, you can simply use "Copy Web Site".
I hardly use web services, but just noticed now when I created one, the CS file was dumped in the App_Code folder. Is that a new thing?
I always thought it behaved much like an Aspx or Ascx file with the nested code behind CS file.
That's because you are using a Web Site in contrast to Web Application. Web Sites are compiled dynamically at runtime by the ASP.NET runtime. In this model all code goes into the App_Code special folder. When deploying you need to upload your source code as well.
On the other hand a Web Application is compiled. You can place the code wherever you like and for things like .ASPX, .ASCX, .ASMX, .ASHX, ... Visual Studio nests the code file next to the markup.
We had an asp.net 1.1 application that we recently migrated to 3.5. We are facing some problems when we do code modification on the migrated application. Here is what is happening
In the asp.net 1.1 application we have the page directive codebehind="ePC.aspx.cs". This migrated fine.
We made some code changes to the .cs file. Say for example, we added a button and added the event handler to the button.
This new functionality was not getting executed properly.
We changed the codebehind directive to codefile directive
Now it is working fine. But during deployment, it asks that the .cs file also be deployed along with the aspx page. We are not sure why this is happening.
I have attached an example page directive
In VisualStudio with CodeFile
<%# Page language="c#" Codefile="ePC.aspx.cs" AutoEventWireup="True" Inherits="SPUniversal.Web.ePC" %>
After publishing the website
<%# page language="c#" autoeventwireup="True" inherits="SPUniversal.Web.ePC, App_Web_eu_mdesx" %>
The App_Web_eu_mdesx got generated automatically in the published website. I don't understand what is going on here. Can you explain?
For 2.0 sites, you have several options of how ASP.Net handles your web site. You can use default compilation, or pre-compiled sites. If you use default compilation, you need to have the source files on the server because inn this mode, ASP.Net will re-compile the website dynamically if it detects any changes to any of the source .cs or .aspx files.
You may want to look into the pre-compilation options available. By pre-compiling your site when you deploy it, you won't necessarily have to put the .cs files on the server.
I am developing a web application. When I build the application I can see the statement "Build Succeeded" in status bar even the syntax of object declaration is wrong in a aspx.cs file. I cleaned the solution again I tried to rebuild the application. But I did not get any error. If I am adding any block of code in that page it is not executing in run time.
Are you using a Web Site Project or Web Application Project?
I've had to work on a Web Site Project where you'd only get compiler errors at runtime because of the way Web Site Projects handle compilation of code behind.
Hard to assess the exact situation without seeing the structure in the Visual Studio solution. Can you verify that the .aspx page you are working on has its Page directive tag pointing to the correct .aspx.cs code-behind file you are modifying?
<%# Page Language="C#" AutoEventWireup="true" CodeFile="I_AM_MODIFYING_THIS_PAGE.aspx.cs" Inherits="I_AM_MODIFYING_THIS_PAGE" %>