views:

99

answers:

5

hi, in order to find the server spec. i've created a file in the root dir in my website called spec.htm and entered this content as i was offered by another user:

<html>
    <head>
        <title></title>
    </head>
    <body>
   @ServerInfo.GetHtml()
    </body>
</html>

but i only get a copy of the code in my browser and it doesn't run it,
what the problem might be?

EDIT: i think that the problem is that i'm not using IIS.
is there a way to do so without using IIS?

thanks

A: 

Are you setting the Content-Type header correctly. If not set to text/html or similar, the browser or framework may set the content-type to text/plain which will not render the html at all.

You can check this in Firebug in the Net tab, expanding the response that is associated with the page you are serving, and looking in the Headers tab. If the Content-Type header is anything besides text/html or text/xhtml, then you need to find a way to make your web server set that header properly

TokenMacGuy
i entered this specific code in my html file as i was told. are there any other lines i need to add? if so, which lines do i need to add? thanks for the fast reply!
yishai
i checked in firebug and in the response header the Content-Type is : text/html, this is in two servers i'm using
yishai
What about viewing the source you are serving? You don't need a plugin to check this, just pick view source, make sure the code isn't being escaped...
TokenMacGuy
i didn't undetstand the answer, where should i check the source? on my website?
yishai
Open the browser, load the page, find the menu option that says `view source`. read the source and make sure the code isn't being double escaped or some such nonsense.
TokenMacGuy
i tried it and it display the source as expected, with the code line @serverInfo.getHtml()
yishai
A: 

The problem is that your webserver is not set up to serve HTML files through the ASP.NET interpreter. Change the extension to .aspx (i.e., use the same code, but call it spec.aspx).

Sean Vieira
i tried what you told me but it still does the same thing, and copy the code into the browser.
yishai
+1  A: 
rockinthesixstring
i've seen this site in my search, i will try this again, BTW i'm using asp.net not LINUX.
yishai
i think that my browser doesn't recognize the extention .cshtml so it doesn't work.
yishai
have you tried using a .aspx or a .htm extension?
rockinthesixstring
i've tried, it didn't work. what did you mean by RAZOR? is there a way of doing the same operation without RAZOR?
yishai
Can you double check to make sure you have [.NET 4.0](http://www.microsoft.com/net/) and [WebMatrix](http://www.asp.net/webmatrix) installed? Razor is part of WebMatrix
rockinthesixstring
i don't know, my website is located on a paid server. if the code doesn't work it means that the serfver doesn't have webmatrix?
yishai
That's most likely the situation. Check out the [WebMatrix Getting Started](http://www.asp.net/webmatrix/tutorials/1-getting-started-with-webmatrix-and-asp-net-web-pages) section for more info.
rockinthesixstring
ok i've read the article but if my server doesn't support WebMatrix then i can't use the code? i think that some of the servers has an option of installing software on the server, if so it is possible to install the software and then running the code?
yishai
yes, or ask the server admin if they're willing to install it... though I doubt they will since it's still in Beta.
rockinthesixstring
ok thanks! i will try to do it
yishai
A: 

let me guess its just showing up "@ServerInfo.GetHtml()" on a webpage. This does nothing if you put it simply in a body tag of a html page. If you are running IIS make sure you are saving as .aspx and not .html

Spooks
i think i've understand my mistake, i run the html file like this: www.mysite.com/spec.aspx directly from the browser and not by using IIS
yishai
is there a way to do so without using IIS?
yishai
@yishai well you need some sort of web server to host your code, and if you are using ServerInfo.GetHtml() which is asp.net related you will need a IIS. Basically if your server is running Windows it will already have IIS, if its running Linux its probably running Apache, where ServerInfo.GetHtml() won't work. Though if you still want the specs you could just asking your host. (assuming you have one)
Spooks
He also needs "WebMatrix" installed. See my answer
rockinthesixstring
i've asked my host and they won't let me know those details and i need them for my project...
yishai
+1  A: 

@ServerInfo.GetHtml() is a Razor view engine syntax. Try saving your file as .cshtml or .vbhtml

ajay_whiz
He also needs "WebMatrix" installed. See my answer.
rockinthesixstring