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.
Related
I have a basic ASP.NET website running under IIS. I didn't publish it, so it's not precompiled or anything.
I was under the impression that if I modify any of the code under any *.aspx.cs file, the site would compile just-in-time and be updated to show those changes.
However, that's not the case. It doesn't reflect my changes and still runs the old code which is in the websitename.dll under the bin folder. Removing that file throws an error.
Is there a way to dynamically modify and run code in an IIS website?
EDIT: the .aspx files do reflect any modifications, it's the .aspx.cs that doesn't work.
It appears that your site is an ASP.NET web application instead of a website. Look at the .aspx file.
In a web application it looks like this:
<%# Page Language="C#" CodeBehind="Default.aspx.cs" Inherits="WebApplication._Default" %>
In a web site it looks like this:
<%# Page Language="C#" CodeFile="Default.aspx.cs" Inherits="_Default" %>
So if your aspx contains CodeFile directive, changes to the code behind will be dynamically picked up.
If it is a web application, you can get rid of the code behind files and any changes would require recompilation.
I have published a asp.net website using visual studio. However, I wish to make changes to a web page but I found out that the published site only have .aspx extension files and there is no code-behind .vb file which is like development.
Is there any way for me to edit without republish again? Or can I convert the published website back to original as I do not have any backup for the published files.
Download all the files from the server and use something like a reflector to get the source code from the binary/bin folder.
And for future always use a source control, I use dropbox.
The dll's are just the compiled assemblies of your source code. You can manually update any of the dll's that are updated without going through the whole publishing process again. You may need to make a minor change to your web config file after updating the dlls so as to trigger IIS to reload the latest dlls.
you can change
<%# page language="VB" autoeventwireup="false" inherits="test, App_Web_olnjngph" culture="bg-BG" uiculture="bg-BG" %>
with
<%# Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="test" Culture="bg-BG" UICulture="bg-BG" %>
and edit source code after that inside file test.aspx.vb
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".
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 dont understand what is going on here
If you created the new 3.5 app as a Web Site instead of a Web Application, that could be causing what you see.
Take a look at this old blog post that explains some of the differences here:
Web Site vs. Web Application
I don't think I fully answered your question, but hopefully these breadcrumbs will lead you down the right path.
To add to what CubanX said, even if you did create it as a Web Application (rather than a Web Site), it can still be worth right-clicking your Web Application Project in Visual Studio's Solution Explorer and clicking "Convert To Web Application", even though it already is one.
We found this fixed a few mysterious problems for us - we never figured out why though. :)
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" %>