Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asp.net deploy - Main.Master.cs file not found

Tags:

c#

asp.net

azure

I am currently deploying my website on azure. One of my pages works ok, yet I have another page which uses a master page, which is not loading because I am getting this 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: The file '/Main.master.cs' does not exist.

Source Error: 


Line 1:  <%@ Master Language="C#" AutoEventWireup="true" CodeFile="Main.master.cs" Inherits="ThirdEye.Main" %>
Line 2:  
Line 3:  <%@ Register Src="~/controls/Footer.ascx" TagName="Footer" TagPrefix="ThirdEye" %>

Source File: /Main.master    Line: 1 

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

I can't figure out what I have wrong. I have uploaded the executable, the pages are in the same directory of the bin folder. Do you think I have to add a period or tilde in front of CodeFile attribute or Inherits attribute?

I am using .net framework v4. I cant use 3.5 and I don't think that that should be the problem.

Main.Master

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Main.master.cs" Inherits="Main" %>

Main.Master.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using ThirdEye;

public partial class Main : System.Web.UI.MasterPage
    {....
like image 398
test Avatar asked May 03 '12 18:05

test


3 Answers

Are you using a Web Application project (rather than a Web Site project)? If so, changing CodeFile to CodeBehind should resolve the error.

Web Application deployments are compiled, and do not include the original cs files that are required when you use CodeFile.

like image 147
Eric Avatar answered Sep 21 '22 12:09

Eric


Based on the error above, tt seems the MainMaster.master.cs is not deployed to Windows Azure.

When you add a new Master Page name "MainMaster.master" in your project, have you set its property to "Copy to Output Directory" as "Copy Always" because by default it is not set and due to this this file will not be part of your Windows Azure Package and cause such error.

Would u please verify if that is the case?

like image 42
AvkashChauhan Avatar answered Sep 22 '22 12:09

AvkashChauhan


To make sure the code files (*.cs) get included when you deploy to Azure, go to the Project Properties and under PACKAGE/Publish Web select "All files in this project folder" for the option Items to deploy (applies to all deployment methods)

like image 29
Luis Hermoza Avatar answered Sep 18 '22 12:09

Luis Hermoza