开发者

can asp.net run without .net framework

i am very new to asp.net. I would like to ask can asp.net run without the .net framework? as in can default.aspx run smoothly without the .net framework? I am asking this due to the following existing code which was runned on a web hosting server and another is a private server. I am not sure about the private server details ( going to know in a 2-3 days)...the code goes as...

try
    {
        WebRequest req = WebRequest.Create(General.SiteUrl + "/pages/" + page + ".htm");
        WebResponse resp = req.GetResponse();
        Stream stream = resp.GetResponseStream();
        StreamReader reader = new StreamReader(stream);
        content = reader.ReadToEnd();
    }
    catch { content = "<html><head></head><body>Content not found.&开发者_高级运维lt;/body></html>"; }

the web hosting server manage to run the "Try" successfully whereas the private one always shows content not found....any ideas guys?


People that visit your website will not need the .NET Framework; all they'll need is a browser.

The server that runs your website will need the .NET Framework since ASP.NET is a part of it.

The .NET Framework is required on the Server side for a few reasons (these are just some examples):

  1. Your code is compiled into an intermediate language designed to be platform agnostic. A runtime (The .NET Framework) is required to convert this intermediate language into something the machine can understand. This is accomplished by the JIT.
  2. There are several libraries in ASP.NET; System.Web.dll; for example. These are distributed as part of the .NET Framework.
  3. The code is hosted inside of a virtual machine (in the non-traditional sense). The virtual machine takes care of a lot of heavy lifting for you; such as security; garbage collection; etc. Again; this is all part of the .NET Framework.

EDIT:

I think you are asking the wrong question here. You ask wondering why your code is going inside of the catch block and returning Content not found. The .NET Framework is properly installed since the catch block is being called; in fact it couldn't get nearly that far without the .NET Framework.

You need to figure out what exception is being thrown inside of the try block that is causing it to go into the catch block. You can achieve this with a debugger; logging; or temporarily removing the catch block all together to get the server to let the exception bubble all the way up to the top. For example; if you change your code block to look like this:

    WebRequest req = WebRequest.Create(General.SiteUrl + "/pages/" + page + ".htm");
    WebResponse resp = req.GetResponse();
    Stream stream = resp.GetResponseStream();
    StreamReader reader = new StreamReader(stream);
    content = reader.ReadToEnd();

The exception details will be displayed in the browser (provided you have debugging turned on). What error is displayed without the try / catch?


No, .Net code will not run without support of the .Net framework. Because code written in .Net language will be compiled and converted to IL (Intermediate Language) Code.


The .NET framework, or some variation of, e.g. Mono, is not required on the client side. This is a requirement of the server which is serving the pages.

When data is sent to the client via HTTP, it is translated into HTML. So all the client would need would be a browser capible of consuming HTML and running any scripts associated with that site.


the .net framework is the foundation that powers this code

try
    {
        WebRequest req = WebRequest.Create(General.SiteUrl + "/pages/" + page + ".htm");
        WebResponse resp = req.GetResponse();
        Stream stream = resp.GetResponseStream();
        StreamReader reader = new StreamReader(stream);
        content = reader.ReadToEnd();
    }
catch 
    { 
        content = "<html><head></head><body>Content not found.</body></html>"; 
    }

so in short, "no", you must have the .net framework installed on the server that is hosting your website.

On the other hand however, on the client side, your website visitors do NOT need the .net framework to "view" your website.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜