Ber53rker
Ber53rker

Reputation: 1038

ASPX can't seem to find my code behind files?

For whatever reason my .aspx will only recognize the code behind when the Page directive is using CodeFile and not CodeBehind. Also, it gives a parser error on runtime. But I need CodeBehind to publish the site.

I'm out options here. Everything I've googled so far hasn't panned out. Why can't CodeBehind be used?!

.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/App/Masters/Default.Master" AutoEventWireup="true" CodeBehind="BlogPost.aspx.cs" Inherits="WebApplication.App.Templates.BlogPost" %>

.aspx.cs

namespace WebApplication.App.Templates
{
    public partial class BlogPost : BaseTemplate
    {

Upvotes: 3

Views: 11477

Answers (1)

Jesse Webb
Jesse Webb

Reputation: 45293

Maybe your .csproj file was corrupted somehow?

Check to see that the entry for your file(s) look like this in your project file:

<Compile Include="BlogPost.aspx.cs">
  <DependentUpon>BlogPost.aspx</DependentUpon>
  <SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="BlogPost.aspx.designer.cs">
  <DependentUpon>BlogPost.aspx</DependentUpon>
</Compile>

Upvotes: 4

Related Questions