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.
Related
I developed a simple web application on my localhost successfully. The next step is to port over to a remote server. IIS Manager has been configured and a virtual directory has been set. I have copied 2 files over, the page VB and .aspx file.
On the top of the aspx file, I have <%# Page Language="VB" AutoEventWireup="false" CodeFile="ASPWiki.aspx.vb" Inherits="ASPWiki" %>'. When I try to run, it shows Server Error: 404 File or directory not found.
When i changed it to <%# Page Language="VB" AutoEventWireup="false"%>, the page can be displayed but the asp controls cannot be bind as the mysql coding is at my vb file. Any advice on what is the issue? Could it be due to the binding i used?
The error only happened after the files were placed in the server.
Seems like an easy-to-fix error, but I've been banging my head on this for a while. App works fine in the VS built-in webserver, but not after moving it to the dev server with IIS7.
The default.aspx file refers to the master page in the page directive...
<%# Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="MyApp.Default" %>
Site1.Master is in the site's root directory, along with default.aspx. The folder permissions are read to Everyone at this point.
This is an intranet site so IIS authorization is anonymous disabled, windows auth enabled, impersonation enabled. App pool is .NET v4, managed pipeline integrated.
I've looked through this site and others for answers and while others have had the same problem, it was for different reasons.
Thanks.
I had the same issue when we moved our site from one server to another. Our new site is on a VPS at a good hosting company (SoftSysHosting.com) and their tech support created a virtual directory of to where our website/app is. That solved it!
I could solve this issue by removing the CodeFile="..." Option in the first line in the Site.Master:
<%# Master Language="C#" AutoEventWireup="true" CodeFile="Site.Master.cs"
inherits="CG.PresentationLayer.WA.MasterPage" %>
into:
<%# Master Language="C#" AutoEventWireup="true" Inherits="MyApp.MasterPage" %>
I have had a similar issue before. The underlying problem is that I assumed that the paths would stay the same and they did not. Log into your dev server and navigate to your master page. Open the page's properties in Explorer and view the path. Now in a test page on your application run a HttpRuntime.AppDomainAppPath() and view where the app is running from. From there you can see where the mismatch is taking place.
Suppose if you are having the root dir of your website or webapplication as given in the pic like "WebApplication1". This is your root folder of the site.
So just copy and paste the content inside the root folder "WebApplication1" to the "root folder" "/" of the FTP address.
Not: dot not copy with root folder WebApplication1. just copy the content inside the root folder.
Your Dir Structure
==+WebApplication1
====Properties
====Referance
====PropertiesSite1.Master
====Web.config
====Webform1.aspx
I am having a problem while publishing my website on the IIS server, i don't have direct access to it so i have to rely on some one else to configure my website on the IIS.
however when i upload my website this error comes up:
Line 1:
<%# Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" title="Untitled Page" %>
Line 2:
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
Parser Error Message: The file '/server/website/MasterPage.master' does not exist.
my masterpage is in the root folder of the website and default.aspx is on the root also, i have searched on internet for answer but the best i have found is changing MasterPageFile="~/MasterPage.master" to MasterPageFile="./MasterPage.master" but haven't tried yet till Monday.
i would appreciate your help.
(i)Make sure that the user account that the server is running under has permissions to access that directory.
(ii)When using "~" in a file path, make sure that the current application deployment believes the root directory is the same as it was before.
(iii)Open IIS, right-click on the virtual directory folder for this site, and selected "Convert to Application." Refresh and check again.
I just had this problem and got it fixed. How? I moved all the files up to the root directory of my website.
Formerly, I put them in a folder inside another folder in the root folder. I am still wondering why I did that :D Anyways it is all fixed now and running without showing any annoying 'Parser Error' and it is perfectly reading and updating the database accurately.
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
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.