views:

167

answers:

2

i created a new class called HTMLRenderer and i am calling it from my aspx view code

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

and i am using it

<% HtmlRenderer.RenderHtmlPage(Html, Server.MapPath("http://www.salemgolfclub.org/Members/newletters/welcome.html" ) ); %>

and i get the error

d:\Adam\Code\CSharp\Asp.net\Adam\Views\Home\Index.aspx(2): error CS0234: The type or namespace name 'Content' does not exist in the namespace 'Golf' (are you missing an assembly reference?)

The build compiles and the Content namespace DOES exist?

any suggestions on whats going wrong here

+2  A: 

Add this line to your View (SO - How do I use an extension method in an ASP.NET MVC View?):

<%@ Import Namespace="Golf.Content" %>

And use Html.RenderHtmlPage() then:

<% Html.RenderHtmlPage(Server.MapPath("http://www.salemgolfclub.org/Members/newletters/welcome.html")); %>
eu-ge-ne
i have this line but when i run it blows up saying that it can't find this namespace CS0234: The type or namespace name 'Content' does not exist in the namespace 'Golf' (are you missing an assembly reference?)
ooo
+2  A: 

You can also add it to web.config so you don't have to add it to every page. This post talks about registering controls http://haacked.com/archive/2006/11/14/Register_Custom_Controls_In_Web.config.aspx

but namespaces work in a similar way. Just use the section instead of controls.

Haacked