Installing a ASP.NET application - asp.net

Ok, this has got to be a super simple problem. I just can't seem to find the answer anywhere. First - I'm not a web developer of any kind, I'm an old school c programmer - so don't flame me for what's probably something quite trivial :)
I need to write a small proof-of-concept web app using ASP.NET. My first attempt here is to create a "Hello World!" app. So I opened up Visual Studio, and made a new web application. I have my Default.aspx file that calls a C# function that is inside the helloworld.dll created automatically by Visual Studio.
I installed IIS on my local machine and created a virtual directory in the wwwroot subdirectory. I put the Default.aspx and helloworld.dll in that directory. Now when I browse to that page I see the following.
Server Error in '/test' 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 'HelloWorld._Default'.
Source Error:
Line 1: <%# Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="HelloWorld._Default" %>
Line 2:
Line 3: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Source File: /test/default.aspx Line: 1
Obviously, IIS doesn't know where to look for the .dll or anything like that. I just don't know how to register the .dll with IIS (or whoever manages that stuff in .net) so that it can find the functions it need.
Can someone let me know how to "install" an ASP.NET application on IIS?

Your best bet is to use 'Publish website' from the Visual Studio Solution Explorer.
Chris Lively adds:
Just a minor add: Publish Website can
be found by Right Clicking on the
project name. The command will be
named "Publish..."

You do not need to move the files to the wwwroot directory manually. A virtual directory in IIS points to any folder in the file system to look for the appliction.
Follow these steps if you are using IIS6:
Open IIS
Under "Web Sites", right-click "Default Web Site"
Select "New"
Select "Virtual Directory"
Type in a name for your new app.
Select the path of your application. By default this is usually something like C:\Your Documents\Visual Stuido 2008\Projects\Your Project Name
Leave the acess permissions as they are.
Click Finish
If you browse to "http://localhost/TheNameOfTheVirtualDirectory/Default.aspx" you should be able to view the page.

I would recommend the solution of Rich B. And something else... DLLs are in a folder called "bin". Not at the root of the folder.

Related

IDE says MasterPage not found, but builds/runs fine

I am stumped as to why my pages are saying the MasterPage cannot be found, even though the MasterPages are where they are specified. For example:
In default.aspx
<%# Page Title="Welcome" Language="C#" MasterPageFile="~/Master.Master"
AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="My_site.default" %>
In the above line, "~/Master.Master" is underlined in green. Hovering with my mouse shows a balloon that reads File '~/Master.Master' was not found. Master.Master definitely exists in the root folder of my site. The site builds fine and all of my pages DO find ~/Master.Master when ran on either my local PC or when uploaded to my hosting account.
The biggest annoyance is that I can't view my pages in the VS IDE because it says The Master Page file '~/Master.Master' cannot be loaded. Correct the problem in Code view. I see nothing to fix...
I have completely deleted the /obj/Debug and /obj/Development folders, clicked to Clean the entire solution, and done a complete build. Every page that uses a Master Page on my site is telling me this.
After running into some problems with long filename errors (unrelated issue) I moved my solution/project to a folder off of my C:. I named the solution folder C:\My_Site and inside of it there is a project folder called My_Site. The full path to my project files is C:\My_site\My_Site.
If I change MasterPageFile="~/Master.Master" to MasterPageFile="~/My_Site/My_Site/Master.Master" then the IDE stops reporting an error and will allow me to view pages in design mode without a problem - although the site will not build this way. The compiler reports problems that the Master Pages cannot be found.
I read a post here on SO - Error: "The file '/MasterPages/MainMaster.master' does not exist." (Yes, this file does exist!) but my files are not located in a virtual folder. I use IIS Express and so am pretty limited with configuring it. I am uneasy about right-clicking my project and converting it to anything. I'm not sure what the effect of that would be.
Anyone have an idea what's possibly happening and how I might resolve this?

ASP.NET could not load type 'WebApplication1.Global'

I created a project (ASP.NET empty web application) WebApplication1.
I also have Default.aspx/login.aspx/GoogleCallBack.aspx
when I run the application, the error shows
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 'WebApplication1.Global'.
Source Error:
Line 1: <%# Application Codebehind="Global.asax.cs" Inherits="WebApplication1.Global" Language="C#" %>
Source File: /global.asax Line: 1
Does anyone know how to fix it ? thank you
Just Check Project -> Properties -> Web
Project Url --- Click on (Create Virtual Directory)link => This will ask you to map to correct folder location say ok.
This problem Occured when we move our project to different directory and IIS still refers to old directory.
Does your project have a "Global.asax.cs"? If so, does it compile?
F5 is for "Debug." This is about building the solution. Ctrl+Shift+B would be the hot-key combination to build and look for compiler errors.
This topic is a duplicate of "Parser Error Message: Could not load type" in Global.asax.
The most voted answer is provided by Facio Ratio: Your local web server is running different code than what you're actually working on. Ensure you have stopped debugging, stop your local web server, clean and rebuild as Peter suggested, double-check your global.asax and global.asax.cs, and try again. If this doesn't work and you are using local IIS, try removing the site in IIS Manager and recreating it manually.

WCF and ASP.Net Precompile

Have a WCF service in a "Services" directory in my asp.net web app. In
/Services/MyService.svc
/Services/MyService.svc.cs
Everything works when copying my source code to the virtual directory. We were really hoping to precompile the code for various reasons, but when we do the service breaks. I am assuming becuase now the ".cs" file is precompiled and there no longer is a "MyService.svc.cs" in the "/Services" directory.
The Error
Error: Cannot obtain Metadata from http://myurl.com/services/MyService.svc
My .svc mark up is the standard:
<%# ServiceHost Language="C#" Debug="true" Service="MyNamespace.MyService" CodeBehind="MyNamespace.MyService.svc.cs" %>
Is there something I am doin wrong, or that I can change on the WCF client/service to allow for ASP.net precomilation?
Assuming you're talking about a precompiled site, take a look at this blog post. Basically the site has to be updatable.
One of my coworkers found this and it works. It is not the best solution, but it works.
http://social.msdn.microsoft.com/forums/en-US/wcf/thread/8c897f8e-2143-450e-a9f4-97d1f8702da7/
EDIT:
Even better solution...We use a deployment project and it seems that the project specifies the project name as the virtual directory path unless otherwise specified. We opened up our deployment project file and updated the below node to the appropriate virtual directory name:
<SourceWebPhysicalPath>..\MyVirtualDirectory</SourceWebPhysicalPath>

Web Service fails when referencing it in another site in IIS

I've got a C# 3.5 web service that works fine when its accessed at http://domain/foo/bar/WS.asmx
The /foo/bar part could change in the future so I want to give people a more stable URL that I could update without requiring any changes from them. I created a site in IIS and set it's Home Directory to where WS.asmx is. Now when I try to access it from http://domain2/WS.asmx, I get:
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 create
type 'Namespace.WS'.
Source Error: Line 1: <%# WebService
Language="C#" CodeBehind="WS.asmx.cs"
Class="Namespace.WS" %>
The assemblies in both cases are at http://domain/bin but when I come from domain2 it doesn't seem to know where to find the \bin that is 3 folders up in the file system.
The namespace/classes are more descriptive than that, I just made them basic for the purposes of this question.
Sorry, AFAIK you can't pull DLLs from explicit file paths outside the root of your website. You generally have two choices:
1) use the /bin directory of the current app (make a copy of the other app's /bin)
2) put the DLL into the Global Assembly Cache (GAC)
BTW, this has been asked in a few other spots on SO, like here.
One thing you could do, if your /bin DLLs are only used inside /foo/bar/, is to convert into an IIS application, and then move the DLLs into a new /foo/bar/bin directory. Then you'd only have one copy of the DLL's to manage.

Can't access bin folder assemblies from virtual directory under site in a ASP.NET deployment

I have an ASP.NET web application which has 3 projects to handle 3 different layers of the application (UI , BL and Data Access). When I publish the UI project a directory called Precompiled will be created in the solution and files will be available there. This folder will have a BIN directory which holds required DLLs (referenced DLLs and DLL of Business Layer project & DLL of DataAccessLayer Project) too.
This works fine. Now I want to use the same BL and DataAcess layer to run multiple UIs (websites). I want to have website called WebsiteA, WebSiteB, MyWebSite1, ShyjusWeb etc. I want to create virtual directory for each one of these. So I created a website and under that i created Virtual directories for the above sites. I put index.asp (of the UI project I had in my solution) in the Folder which is mapping to one virtual directory and when trying to access, I am getting an error like the following:
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_lls0_qzf'. Make sure that it is compiled before accessing the page.
Source Error:
Line 1: <%# page language="C#" autoeventwireup="true" inherits="index, App_Web_lls0_qzf" %>
Line 2: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Line 3: <html xmlns="http://www.w3.org/1999/xhtml">
Source File: /websiteA/index.aspx Line: 1
It seems like the page is not able to access the required DLL's from the BIN folder. Is there any way to solve this? IIS 6.0 I am playing with. My folder hierarchy is like this now:
Root Folder - > Bin folder, Various UI related files & folders a folder which is converted to a virtual directory now (WebSiteA). Inside WebSiteA, I have inde.aspx, which is the same copy as of the index.aspx available in the root folder.
I need to have the same website (copy with only some CSS changes for each site). If I copy the Bin folder from my root and paste it in each of the virtual directory folders along with the index.aspx, it's working. But I don't want to have same BIN folder for each sites. I want to have only one BIN, which should be in the ROOT folder
I think you have gotten yourself in a muddle.
The file you mention (App_Web_lls0_qzf) appears to be the compiled DLL for the first specified UI/BL/DAL combination and I am unfortunately confused by your description of your folder structure.
I am not clear about whether you are wanting multiple COPIES of the same site or whether each site is different.
Have you not tried creating the 4 websites, and referencing the the common BL and DAL projects?
Remember that your file structure and your IIS structure do not have to be the same, i.e.
c:\sites\website1
c:\sites\website2
c:\sites\website3
c:\sites\website4
and in IIS
Master Web Site
Web1
Web2
Web3
Web4
Remember inheritance! - DLLs and references in your master website will be inherited into your virtual directories. You may also wish to consider creating web app pools for each web site.
Add a reference to your BL and DAL projects from the website project that you created

Resources