string GenerateRequestUri(string spellCheckEndpoint, string text, SpellCheckMode mode) { string requestUri = spellCheckEndpoint; requestUri += string.Format("?text={0}", WebUtility.UrlEncode(text)); // text to spell check requestUri += string.Format("&mode={0}", mode.ToString().ToLower()); // spellcheck mode - proof or spell return(requestUri); }
/// <summary> /// Enables processing of HTTP Web requests by a custom HttpHandler that implements the <see cref="T:System.Web.IHttpHandler"/> interface. /// </summary> /// <param name="context">An <see cref="T:System.Web.HttpContext"/> object that provides references to the intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests. /// </param> public void ProcessRequest(HttpContext context) { string engine = context.Request.Form["driver"]; string lang = context.Request.Form["lang"]; //PHP defines an array passed back in the form with "[]" string[] text = context.Request.Form.GetValues("text[]"); string suggest = null; //if the action is suggest set the suggestion word if (context.Request.Form["action"] == SUGGESTIONS_ACTION) { suggest = context.Request.Form["word"]; this._currentSpellCheckMode = SpellCheckMode.Suggest; } string result = SpellCheck(text, lang, engine, suggest); context.Response.ContentType = "application/js"; context.Response.Write(result); }
/// <summary> /// Enables processing of HTTP Web requests by a custom HttpHandler that implements the <see cref="T:System.Web.IHttpHandler"/> interface. /// </summary> /// <param name="context">An <see cref="T:System.Web.HttpContext"/> object that provides references to the intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests. /// </param> public void ProcessRequest(HttpContext context) { string engine = context.Request.Form["driver"]; string lang = context.Request.Form["lang"]; //PHP defines an array passed back in the form with "[]" string[] text = context.Request.Form.GetValues("text[]"); string suggest = null; //if the action is suggest set the suggestion word if(context.Request.Form["action"] == SUGGESTIONS_ACTION){ suggest = context.Request.Form["word"]; this._currentSpellCheckMode = SpellCheckMode.Suggest; } string result = SpellCheck(text, lang, engine, suggest); context.Response.ContentType = "application/js"; context.Response.Write(result); }
private string GenerateRequestUri(string bingSpellCheckEndpoint, string text, SpellCheckMode spell) => $"{bingSpellCheckEndpoint}?text={WebUtility.UrlEncode(text)}&mode={spell.ToString().ToLower()}&cc=MX&mkt=es-MX";