Take the 2-minute tour ×

I have in my funcs.cs file:

using System;
using System.Collections.Generic;
using System.Web;

public static class AuthData
    public const string USERNAME = "zheref";
    public const string PASSWORD = "Altairis";

And I'm trying to access the USERNAME and PASSWORD constants in my AuthData class from my Razor Code (auth.cshtml file):

    var u = Request.Form["username"];
    var c = Request.Form["password"];

    if(u == AuthData.USERNAME && c == AuthData.PASSWORD)

This is generating a Compilation Error: "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."

If that's not the way I'm not sure how to do that. Thanks.

share|improve this question
You probably just need a @using statement. If AuthData isn't in a namespace, then it ought to be. –  Jacob Oct 9 '12 at 2:52
add comment

1 Answer

up vote 0 down vote accepted

You need to put your funcs.cs file in your App_Code folder, if it doesn't exist create it. This assumes that all namespaces are resolvable and you don't need any using statements in your razor file.

share|improve this answer
Worked perfectly with the App_Code folder. Thanks so much –  Zheref Oct 9 '12 at 2:57
add comment

Your Answer


