Home > Net >  Use HttpListener do web server, the output HTML, how to make the HTML and CSS and js in key work?
Use HttpListener do web server, the output HTML, how to make the HTML and CSS and js in key work?

Time:10-16

Want to do with HttpListener web server, the output HTML page content, but within the HTML reference external CSS and js doesn't work,

The output page content is as follows:




<meta charset="utf-8" & gt;
<script SRC="https://bbs.csdn.net/topics/plus/jquery-2.1.1.min.js" & gt; </script>
Document

<body>




The button and the text hello can display properly, is only used by the button style did not perform, the style is in the root directory service plus/button. The CSS,
The root directory of the plus/jquery - 2.1.1. Min. Js also didn't perform,

How do I make HTML diversion work style and js?

CodePudding user response:

HttpListener?
Even if it is only a static web site, you can want to write a lot of code
Others request the HTML, CSS will continue to request references, js file, such as when returned to it, you must complete to static routing file parsing

CodePudding user response:

@ stherix saw a lot of people say use HttpListener web service can be done, can abandon the IIS, we'll try, you continue to request the CSS, js, in code what should I do with these? Can give some reference code?

CodePudding user response:

refer to the second floor kucao response:
@ stherix saw a lot of people say use HttpListener web service can be done, can abandon the IIS, we'll try, you said to request CSS, js, in code what should I do with these? Can give some reference code?


Use HttpListener too troublesome, want to write a lot of things, don't IIS options are a lot of
OWIN, for example, could be selfhost kestrel

CodePudding user response:

??????????????
Output HTML, or HTML, as for the js, that's another visit (static files)

Saying you just want to abandon the iis, simple, ancient Owin. Self. The host, the later Nancy, netcore is fine now, (netcore can run on Linux, you said he iis? And Java spring boot, the two can be directly as the web server host, simply don't have to rely on iis, tomcat)

CodePudding user response:

Thank you all for the great god of the answer, I from the Internet to find some Owin. Self. The host data, most is done with Owin. Self. Host the web service, can see the effect before use HttpListener like with me, don't see how to deal with the static page + js + CSS specific application examples, how can I put the static web site is ready to Owin. Self. The host, so that customers can access the web site page? Can you provide some code or data connection address?

CodePudding user response:

Owin. Self. Behind the host a static file plug-in class

https://www.nuget.org/packages/Microsoft.Owin.FileSystems/

This is a static file support, that is, what do you want to (HTML, js, CSS) support this type of file

CodePudding user response:

The above provides a virtual file system

Microsoft. Owin. StaticFiles

In the file system provides, on the basis of static file class exclusive offers

CodePudding user response:

The path you have any question, if be public JS, can use the network address
  •  Tags:  
  • C#
  • Related