Hi, I am new to Umbraco and I am in the process of migrating a some existing websites across.
I have some aspx.cs files handling contact form emails etc. and want to use these in Umbraco to save starting again with those features. I have set up a template for the contact form and I dropped the associated aspx.cs file (just sends an email with the contact form content) into the Umbraco templates folder. But I am getting this error (it works fine outside of Umbraco):
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the
compilation of a resource required to service this request. Please
review the following specific error details and modify your source code
appropriately.
Compiler Error Message: ASPNET: Make sure that the
class defined in this code file matches the 'inherits' attribute, and
that it extends the correct base class (e.g. Page or UserControl).
Source Error:
Line 5: using System.Web.UI.WebControls;
Line 6: using System.Net.Mail;
Line 7: public partial class SendMail : System.Web.UI.Page
Line 8: {
Line 9: protected void Btn_SendMail_Click(object sender, EventArgs e)
using System; using System.Collections.Generic; using System.Text; using System.Net; using System.Web.UI.WebControls; using System.Net.Mail; public partial class SendMail : System.Web.UI.Page { protected void Btn_SendMail_Click(object sender, EventArgs e) {
Don't use anything with .aspx in the filename with umbraco. Umbraco works with (nested) Masterpages. The template you've added in umbraco exists on the HDD as template_name.master. Rename your .aspx.cs page to .master.cs, correct the <%@ Master %> page directive:
CodeFile="SendMail.master.cs"
and change
public partial class SendMail : System.Web.UI.Page
into
public partial class SendMail : System.Web.UI.MasterPage
Importing aspx.cs files into Umbraco
Hi, I am new to Umbraco and I am in the process of migrating a some existing websites across.
I have some aspx.cs files handling contact form emails etc. and want to use these in Umbraco to save starting again with those features. I have set up a template for the contact form and I dropped the associated aspx.cs file (just sends an email with the contact form content) into the Umbraco templates folder. But I am getting this error (it works fine outside of Umbraco):
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.Compiler Error Message: ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl).
Source Error:
Line 5: using System.Web.UI.WebControls; Line 6: using System.Net.Mail; Line 7: public partial class SendMail : System.Web.UI.Page Line 8: { Line 9: protected void Btn_SendMail_Click(object sender, EventArgs e)
In my Master template I have this:
<%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>
In my Contact Page template I have:
<%@ Master Language="C#" MasterPageFile="~/masterpages/Master.master" AutoEventWireup="true" CodeFile="SendMail.aspx.cs" Inherits="SendMail" %>
My aspx.cs file:
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Web.UI.WebControls;
using System.Net.Mail;
public partial class SendMail : System.Web.UI.Page
{
protected void Btn_SendMail_Click(object sender, EventArgs e)
{
..........................................................
Can I get this working as is in Umbraco or do I need to compile it and wrap in a Macro?
Many thanks if you can point me in the right direction?
Iain
Don't use anything with .aspx in the filename with umbraco.
Umbraco works with (nested) Masterpages. The template you've added in umbraco exists on the HDD as template_name.master.
Rename your .aspx.cs page to .master.cs, correct the <%@ Master %> page directive:
CodeFile="SendMail.master.cs"
and change
public partial class SendMail : System.Web.UI.Page
into
public partial class SendMail : System.Web.UI.MasterPage
Thank you so much, that cured the problem and I have the first website up and running with Umbraco.
is working on a reply...