tags:

views:

73

answers:

4

i have this code in one of my asp.net mvc views:

   <%Html.RenderFile(@"C:\Members\newsletters\welcome.html");%>

I have created an extension on the Html class to read in a file. the code looks like this:

public static class HtmlRenderer
{
    public static void RenderFile(this HtmlHelper helper_, string path_)
    {
        var reader = new StreamReader(path_);
        var contents = reader.ReadToEnd();
        helper_.ViewContext.HttpContext.Response.Write(contents);
    }
}

This all works perfectly when i run in visual studio on my desktop but when i ftp these files to the server, i get the following error in the browser:

Compiler Error Message: CS1061: 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'RenderFile' and no extension method 'RenderFile' accepting a first argument of type 'System.Web.Mvc.HtmlHelper' could be found (are you missing a using directive or an assembly reference?)

The HtmlRenderer class is in a namespace with my controllers so there is no other external assembly reference needed.

Does anyone have any idea how this could be happening or what i am doing wrong ?

A: 

You need to compile the project and then deploy (xcopy or publish from VS) to the server.

Dan
can you be more specific . . in visual studio, i hit build solution and then ftp the bin folder to the server. am i missing something?
ooo
A: 

Googled and found something.Does the server has .net 3.5?

Galilyou
yes. . . it doesn't necessarily have anything specific to do with extension methods as i changed this to a separate class and same issue. it can't seem to find any of my code after i ftp to the server
ooo
A: 

Try to publish the web on a local IIS7 or IIS6.( Right click project "Publish" ). You have a good chance you already get a more specific error during "publish".

If not run the page on your local IIS6 or 7 and see if you get an error.

Malcolm Frexner
A: 

i tried doing a full refresh (deleting everything on the server and republishing and now everything works fine..

so i am happy that everything is working but still have no clue why it wasn't before.

ooo