1

I have a aspx web page with no code behind and a few inline C# methods (webmethods) for a mostly static page.

The following lines of code would return a compile time error were it placed in a code behind page (nothing being returned from the method)

    <script runat="server">
    [WebMethod]
    public static string SomeMethod()
    {
       string result = "hello";
    }
    </script>

Is there a compiler option to turn on the compile time check for inline C# code blocks in a web page ?

Jean-François Fabre
  • 137,073
  • 23
  • 153
  • 219

1 Answers1

1

For regular asp.net:

http://mikehadlow.blogspot.co.uk/2008/05/compiling-aspx-templates-using.html

for asp.net mvc

Compile Views in ASP.NET MVC

Community
  • 1
  • 1
spender
  • 117,338
  • 33
  • 229
  • 351