How does asp.net WebService remove the asmx suffix and webserviceasmx?
There is now a published WebService with the address http://hovertree.com: 2706/UploadExpenseToConstract. asmx
Can I remove the final asmx? Change
Http://hovertree.com: 2706/UploadExpenseToConstract
But the effect is the same as the original one?
Code:
Global. asax
using System;namespace ExampleHoverTree{ public class Global : System.Web.HttpApplication { protected void Application_Start(object sender, EventArgs e) { } protected void Session_Start(object sender, EventArgs e) { } protected void Application_BeginRequest(object sender, EventArgs e) { string hPath= Request.Url.LocalPath.ToString().ToLower(); if (!hPath.Contains("/hovertreewm.asmx")) { if (hPath.Contains("/hovertreewm")) { Context.RewritePath(hPath.Replace("/hovertreewm", "/hovertreewm.asmx")); } } } protected void Application_AuthenticateRequest(object sender, EventArgs e) { } protected void Application_Error(object sender, EventArgs e) { } protected void Session_End(object sender, EventArgs e) { } protected void Application_End(object sender, EventArgs e) { } }}
HoverTreeWM. asmx
Using System. web. services; namespace ExampleHoverTree. htExample. HWebMethod {// <summary> // summary of HoverTreeWM /// </summary> [WebService (Namespace = "http://hovertree.top/")] [WebServiceBinding (ConformsTo = WsiProfiles. basicProfile1_1)] [System. componentModel. toolboxItem (false)] // to allow ASP.. net ajax calls this Web service from a script. uncomment the following lines. By he asked [System. web. script. services. scriptService] public class HoverTreeWM: System. web. services. webService {[WebMethod] public string HLogin (string hUsername, string hPassword) {// return hUsername + hPassword; return (hUsername. toLower () = "hewenqi" & hPassword = "HoverTree ")? "Logon successful": "incorrect user name or password ";}}}
HoverTreeAjax.htm
<! DOCTYPE html>
:
Source code download: http://hovertree.com/h/bjaf/hv6cqe5n.htm
Recommended: http://www.cnblogs.com/sosoft/p/csharpemail.html