Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

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 ?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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

share|improve this answer
    
Thanks - it worked. Also just want to add that using re-sharper helps. – Console.WriteLine Jun 28 '12 at 20:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.