1

How can I create an ASPX page that has the character '.' in its name? If I name the page: "MyName.com", it will give me a lot of errors afterward. I'm using .NET 4

MSDN could do it here. Check the URL.

Here are some of the errors I'm getting:

Error 4 Invalid token '{' in class, struct, or interface member declaration C:\Sample Telerik\AnotherDotSolution\AnotherDotSolution\MyTest.com.aspx.cs 11 2 AnotherDotSolution

Error 2 { expected C:\Sample Telerik\AnotherDotSolution\AnotherDotSolution\MyTest.com.aspx.cs 10 29 AnotherDotSolution

and also in the designer:

Error 8 The type or namespace name 'com' could not be found (are you missing a using directive or an assembly reference?) C:\Sample Telerik\AnotherDotSolution\AnotherDotSolution\MyTest.com.aspx.designer.cs 13 33 AnotherDotSolution

Scotty.NET
  • 12,533
  • 4
  • 42
  • 51
yazanpro
  • 4,512
  • 6
  • 44
  • 66
  • Could this SO be of use? http://stackoverflow.com/questions/11728846/dots-in-url-causes-404-with-asp-net-mvc-and-iis – Nick Sep 19 '13 at 21:02
  • It's not the `.`. I suspect it's the `.com` that's causing confusion – Joel Coehoorn Sep 19 '13 at 21:14
  • @NicholasV. I don't think that that is relevant since it's MVC – yazanpro Sep 19 '13 at 21:34
  • You are going to need to provide some more information. I just added `mypage.this.aspx` to my project, built it and browsed under debug to the page without issue using .NET 4.5. – ethorn10 Sep 19 '13 at 21:42
  • I'm using .NET 4 if that makes any difference. I added that to the question. – yazanpro Sep 19 '13 at 21:44
  • You mention getting "a lot of errors afterward"...care to provide maybe one of these? – ethorn10 Sep 19 '13 at 21:46
  • 1
    To follow your example literally, `MyName.com` isn't a valid file extension for your view. It needs to be `MyName.com.aspx`, which matches the same format as the MSDN article you linked. Additionally this is standard behavior of the file system. You could have a jpeg named `MyImage.png.gif.jpg`. The last dot starts the beginning of the file extension. – The Muffin Man Sep 19 '13 at 21:51
  • You also need to edit your question and tell us or show what errors you're getting. There's a lot of context missing from this. Until then I'm voting to close. – The Muffin Man Sep 19 '13 at 21:53
  • Am I the only person who's getting this problem?! I will modify the question right now – yazanpro Sep 19 '13 at 21:58

2 Answers2

2

Background

The CodeBehind of the aspx file @Page directive determines the name of the class file that needs to contain the class referenced in Inherits. So you could get away with having a dot in the page name as long as you are willing to hand code the class name in the aspx and aspx.cs files.

Webform1.Stuff.aspx

Note the @Page directive or whatever it's called. The CodeBehind and Inherit bits.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.Stuff.cs" Inherits="WebFormsApp1.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    </div>
    </form>
</body>
</html>

Webform1.Stuff.cs

namespace WebFormsApp1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}

I was able to compile and run this page.

Scotty.NET
  • 12,533
  • 4
  • 42
  • 51
1

Your code-behind likely has an invalid class declaration. It probably looks like this:

public partial class MyTest.com : System.Web.UI.Page

And should look like this:

public partial class MyTest__com : System.Web.UI.Page

You will also need to make sure your .aspx uses the proper Inherits:

Inherits="yournamespace.MyTest__com"
ethorn10
  • 1,889
  • 1
  • 18
  • 29