Having problems deploying my .Net web application via FTP - c#

In the past, I've had no problems uploading my web site to my hosting provider but now I'm using .Net 4.5 with Nuget packages and I'm getting errors. Oh and now it's a web Application.
When I look at my file structure, I have 'MySite' as the parent folder, then under that I have the 'Packages' folder (which I assume is where the Nuget files I downloaded are installed). At the same level as the Packages folder, I have another 'MySite' folder which I uploaded to the server via FTP.
Now I'm thinking that the server would need the Packages folder but I don't know where to put it. I also thought about using the Publish feature in VS 2013 but need a .publishsettings file from my hosting provider which I do not have.
Surely there is a way to just transfer the files via FTP?
At the moment I'm getting the following error:
Parser Error Message: Could not load type 'MySite.Global'.
Line 1: <%# Application Codebehind="Global.asax.cs" Inherits="MySite.Global" Language="C#" %>
I cannot see any problem with my Global.asax.cs file at all.

please try this:
Could not load type 'XXX.Global'
"Could not load type [Namespace].Global" causing me grief
I guess the problem is because some dll is missing or your pool of IIS is not configured corretly.

Based on error I think .net version is not property set in application pool.

Related

Why am Igetting the error "Could not load type 'CADE.main.index'." on a new server when I'm using the same code on all other instances, how fix it?

I just checked out my "mixed" (asp classic and .Net) web site source from SVN on a new Windows 2019 Server. When I go to the logon page (.asp classic), it's fine but when you logon and call the main page (.aspx) it throws the error: "Could not load type 'CADE.main.index'" and displays:
Line 1: <%# Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="CADE.main.index" %>
This SVN code is running on 15+ servers, including one 2019 Server. The code behind looks like:
namespace CADE.main
{
public partial class index : BasePage // Override with BasePage
{
IIS and everything under Application Development is installed. IIS serves .asp, .txt, .gif, .png, even .Net handlers (.ashx) and web services (.asmx), just not the aspx pages.
So, I rebuilt the solution with VS2019 and published it, gave administrator permissions on the app pool, gave "Everyone" full permissions on the entire web, deleted the bin directories in both the source and web locations, ensured output path was bin/, cleaned the project, don't think I should change CodeBehind to CodeFile, and tried about every other thing that people have suggested on this web site but nothing has eliminated the error.
Question: How do I fix this error so the .aspx pages loads?
EDIT #1: 15 hours after post
I'm not sure but with this information maybe this should be a new post.
This error ONLY happens on the second web site. IIS is serving two web sites, separating them by host name (web1.com vs. web2.com) in bindings. They both point at the same file structure. Web1's subdirectories are natural while Web2's subdirectories are virtual directories that point to Web1's.
Web1: Normal IIS web
wwwroot
LMW (subweb, LMW/Main/index.aspx is page in question, but works here)
Web2: Second web in IIS, based on host name, uses Web1's folders as virtual directories.
wwwroot
WEB2 (folder under wwwroot)
LMW (virtual directory points to Web1/wwwroot/LMW. LMW/Main/index.aspx gives the error here)
Question: Why doesn't the .aspx work when it's a virtual directory?... it's the same file as is in Web 1?
EDIT #2
It is working but I don't know what I did to fix it. I'm sure I changed something but I don't know what it was. So, I created another web like web #2, New web folder under wwwroot with LMW a virtual directory pointing to Web1/wwwroot/LMW! I'm seriously missing something, Any ideas?
These errors occur if the .aspx page or the Global.asax page contains a reference to a code-behind module and if the application has not been built.
You could try the below method to build the application:
Use the C# command-line compiler (CSC.exe) to run the following command:
csc /t:library /r:System.web.dll /out:mydll.dll myfile.cs
OR
In Microsoft Visual Studio .NET, click Build on the Build menu.
Also try changing CodeBehind="index.aspx.cs" to CodeFile="index.aspx.cs". This change is required when you change project type from website to webapplication or vice versa.
make sure you install the .ne framework feature of iis.
I actually created a brand new web that used a Virtual Directory for it's codebase that is the same code as the other webs.
Index.aspx resides in the /lmw/main directory. I had created an Application on that folder when I was creating the other applications in the web. So, I removed the "Application" from /lmw/main and it worked.

Parse Error in Global.asax after Publishing to Azure

I have deployed my ASP.Net MVC 5 application to Azure Web Apps. All has worked well until I added Application Insights yesterday. Since then, each attempt to publish my site results in a parse error. I've reviewed the application logs and telemetry but cannot discern how things have gone awry. Are there specific changes that need to be made to global.asax in order for Application Insights to place well?
Update:
I found that the web project properties Assembly Name had been accidentally modified (rookie move). I have changed it, cleaned, rebuilt, published all to no avail. Output of parse error is:
Parser Error Message: The type 'MobileFirst452.MvcApplication' is ambiguous:
it could come from assembly 'D:\home\site\wwwroot\bin\licationSeri.DLL' or
from assembly 'D:\home\site\wwwroot\bin\MobileFirst452.DLL'. Please specify
the assembly explicitly in the type name.
I deleted contents from bin folder. The contents of global.asax are as follows:
<%# Application Codebehind="Global.asax.cs"
Inherits="MobileFirst452.MvcApplication" Language="C#" %>
After posting the above update, I reviewed the files deployed to Azure. I deleted the DLL that was causing the error and can now finish testing the site. Word to the wise: check project properties prior to publishing just in case something was accidentally over-typed.

ASP.NET IIS7.5 Parser Error

I have a production system and test system, both running IIS. IN the production system, everything runs fine. In the test system, I have a directed copy of the folder the site code is contained in which is set up as a virtual directory. The App_Code folder is in the root and contains all the .cs files. When running the same site in test, I get a
Server Error in '/' Application.
--------------------------------------------------------------------------------
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not load type 'SPTasks.master'.
Source Error:
Line 1: <%# Master Language="C#" inherits="SPTasks.master"%>
Line 2: <html>
Line 3: <head runat="server">
Source File: /SPTasks/master.master Line: 1
Any idea why this would be coming in test and not in production? Is the code not compiling for some reason?
Thanks!
Some of the comments have asked about MVC, but this looks like a WebForms application - correct me if I'm wrong? In the past I've seen this error if the application has not yet been compiled. You mention that you're copying files across one at a time. Have you actually compiled the application? If there's no dll in the bin folder containing the compiled code for your SPTasks.master.cs class, you'll get this error. As you're not using VS to compile your application, you'll need to use csc directly from the command line as per this MSDN article.
If you have a dll in there, it might be worth looking inside with a decompiler (either Reflector or Jetbrains DotPeek, which is free) to verify that the SPTasks.master.cs class is there.
Another thing to check is that the application pool that the site is running under is configured as .Net Framework Version 2.0 and not 4.0
Your IIS website is probably misconfigured. An IIS "virtual directory" is not the same thing as an application scope.
In IIS Manager, right-click the root of your application and choose "Convert to Application".

Parser Error: Could not load the assembly 'App_Web_ah9y-lsc'

The site works fine when I'm running it locally, I published it and hosted to a hosting space hired by my company via SMART FTP.There is a folder with my company's name eg. 'MyCompany'. It has sub folders such as App Data, App Code, Bin, Httpdocs,Httpsdocs...etc. I transferred my published project'UtilityServices' to Httpdocs. Then i enter www.MyCompany.net/UtilityServices/Customer_Login.aspx i got the following error.
Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not load the assembly 'App_Web_ah9y-lsc'. Make sure that it is compiled before accessing the page.
Source Error:
Line 1: <%# page language="C#" autoeventwireup="true" inherits="Customer_Login, App_Web_ah9y-lsc" %>
Line 2: <%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
Line 3:
Source File: /UtilityServices/Customer_Login.aspx Line: 1
Httpdocs has a bin folder and a webconfig, the hosted UtilityServices has a bin and webconfig. Is this the reason for this error.
I am using VS2008 C# 3.5 Framework.
Well, it is an old question and still many search for a relevant answer to this problem.
You need to change the site to an application in the IIS.
Just open the IIS manager and choose the site which has been compiled. Right click the site and choose "Convert to Application". No need to restart the IIS, but there is no harm if you do that. This will solve the problem.
I've had similar problems when transferring files to a web server - what I presume to be happening is that files somehow get corrupted in transfer, and you get weird assembly names.
What worked for me is, if I could find out what files broke the build on server (if it worked before I uploaded a batch, then I got compile error of this type), I would make minor changes (press space and backspace) to force a save on them, and reupload those files, and in turn that would make server recompile them again and the error would be gone.
Hope this works for you :)
If the app you have in /UtilityServices/ has it's own App_Code folder, etc, then the directory needs to be configured as an Application in IIS. See this link for instructions on how to do this.
If you cannot configure the webserver, try placing the files in your App_Code, bin, etc folders in there corresponding folders at the root of the site.

could not load type <MyNameSpace>.Global

I'm currently working on an ASP.NET 4.0 site using a project-less solution.
By default the global.asax does not have a code-behind file, but after I changed it to
<%# Application Language="C#" CodeBehind="Global.asax.cs" Inherits="MyNamespace.Global" %>
And created an empty Global.asax.cs with the same namespace / class name I'm getting this error at compile time
Error 1 Could not load type 'MyNamespace.Global'. C:\Projects\RiskOptix\Code\RiskOptix.WebApplication\RiskOptix.WebApp\Global.asax 1
I've already tried cleaning out my entire bin folder but to no avail - this is extremely infuriating.
This question has already been asked. Check out this answer. Web site projects work differently from web application projects. Website type projects do not have CodeBehind files instead have CodeFile.
<%# Application CodeFile="Global.asax.cs" Inherits="MyNamespace.Global" Language="C#" %>
CodeBehind = Needs to be compiled ( asp.net 1.1 model) and compiled binary is placed in the bin folder of the website. You need to do a compile in visual studio before you deploy. Good model when you do not want the source code to be viewable as plain text ... for example when delivering to a customer who you not have obligation to provide code.
CodeFile = You provide the source file with the solution for deployment. ASP.NET 2.0 runtime compiles the code when needed. The compiled files are at Microsfot.NET[.NET version]\Temporary ASP.NET Files.
I was not able to run my MVC Web application. It was giving Could not load type <application namespace.Classname> error in Global.asax
I went to Project Properties and set the build>output folder to bin/ which was bin/Debug. Ran it once. It ran fine. And then again set the output folder to bin/Debug. Working fine now.
just to add my 2 cents with a WTF moment, My version of this error was caused by the Global.asax.cs not being included in the Visual Studio Project.
Right clicked on the .cs file, include in project and voila...
HTH
Dave
Yet another way to get this into this problem...
I had my web app open in VS2010, and IIS Express could run it just fine. Later, I opened the same web app, but in a newer branch with VS2012, and the virtual dirs in IIS Express auto-magically updated themselves to the physical dirs for the VS2012 project, without warning. So when I hit F5 to run my web app in VS2010 where I'm debugging, then I got the "could not load type or namespace" error in the global.asax file on one Import Namespace line. Closing both VS instances and reopening just the VS2010 version fixed the problem.

Categories