result = req.GetResponse (); Stream ReceiveStream = result.GetResponseStream (); Encoding encode = System.Text.Encoding.GetEncoding ( "utf-8"); StreamReader sr = new StreamReader (ReceiveStream, encode); Console.WriteLine ( "/ R / N has received response stream"); char [] read = new char [256]; int count = sr.read (read, 0, 256); console.writeline ("HTML ... / R / N "); while (count> 0) {string str = new string (read, 0, count); console.write (str); // add by playyuer s = str; count = sr.read (read, 0 , 256);} console.writeline (""); returnction} catch (e) {console.writeline (E.TOString ()); console.writeline ("/ r / n can not find the request URI, or Its format is incorrect "); Return S;} finally {if (Result! = Null) {result.close ();}}} /// /// domain name /// summary> // / If you support an extension-name resolution, you can also do 1bu.com:) remarks> public static string domain {get {string domain = configurationSettings.appsettings ["Domain"]; if (domain = = NULL || Domain == "") Domain = defaultdomain; return domain;}}
/// /// domain name URL /// summary> public static string domainurl {get {string url = domain.tolower (); if (! url.startswith ("http: //")) {URL = "http: //" URL;} if (! Url.endswith (")) {url = url " / ";} return url;}}
/// /// real address /// summary> /// param> /// returns> public static string realurl (String Rawurl ) {String realur1; realurl = globals.domainurl rawurl.trimstart ('/'); return realurl;} static public string appliologicalPath {
Get {string applicationPath = httpContext.current.request.ApplicationPath;
IF (ApplicationPath == "/") {Return String.empty;} else {return applicationPath.tolower ();}}}}
// Original redirect.cs /// /// Turn URL /// summary> public class redirect: IHTTPHANDLER {public redirect () {}
public void ProcessRequest (HttpContext context) {string rawUrl = context.Request.RawUrl.ToLower (); string realUrl = rawUrl; if {if (rawUrl.StartsWith ((Globals.IsNullorEmpty (rawUrl)!)! "http: //" )) {Realurl = globals.realurl (RAWURL);}} CONTEXT.RESPONSE.REDIRECT (REALUR); context.response.end ();
// Properties public bool isreusable {get {returnaf false;}}}}
// original WebResponse.cs /// /// outputting content /// summary> public class WebResponse: IHttpHandler {public void ProcessRequest (HttpContext context) {string rawUrl = context.Request.RawUrl.ToLower () ; If (! Globals.isnullorempty (rawur)) {// If it is "http: //", it is said to be an absolute path, and you can jump directly if (! Rawurl.startswith ("http: //")) { string realUrl = Globals.RealUrl (rawUrl); // add by playyuer $ at $ Microshaoft.com if (context.Request.HttpMethod.ToLower () == "get") {HttpWebResponse response = Globals.WebResponse (realUrl);
/ / If it is not a text type, jump if (! Response.contenttype.tolower (). StartSwith ("text /")) Context.Response.Redirect (Realull);
// Text type first get the text content, then output directly to the browse. String content = globals.textcontent (response); context.response.write (content);} // add by Playyuer $ AT $ microshaoft.com else // POST {String S = ""; Foreach (String S in Context.Request.form.allKeys) {if (S.Length> 0) s = "&"; s = s "=" context.request. Form [S];} //context.response.write (s); context.Response.write (Globals.getPage (REALURL, S));}} else {context.response.redirect (rawurl);}} else { //} context.Response.end ();
Public bool isreusable {get {returnaf false;}}}}
4. Web.config under the main directory of IIS, such as: c: /inetpub/wwwroot/web.config:
XML Version = "1.0" encoding = "UTF-8"?> httphandlers> /system.web> appsettings> configuration> 5. Running resin and iise: /resin/resin-2.1.16/bin/httpd.exe
6. Access in the IE address bar: http: // localhost submit some data tests! Look at the correct way?! I have a slowed down! Different Baoyu and I have not considered replacing the HREF's URL processing!
转载请注明原文地址:https://www.9cbs.com/read-53651.html