/// <summary> /// Vyhlada vsetky url adresy v texte a vytvori z nich html A tag /// </summary> /// <param name="value">String ktory chceme previest na mvc string</param> /// <returns>MvcHtmlString</returns> public static MvcHtmlString ToMvcHtmlStringWithUrl(this string value) { return(WebUtility.GetMvcHtmlStringWithUrl(value)); }
/// <summary> /// Vypise vsetky podstate informacie z requestu /// </summary> /// <param name="request">Request z ktoreho chceme vypisat informacie</param> public static void TraceRequest(this HttpRequest request) { if (request != null) { StringBuilder builder = new StringBuilder(); builder.Append("Request:"); if (request.AcceptTypes != null && request.AcceptTypes.Length > 0) { builder.Append(Environment.NewLine); builder.AppendFormat("AcceptTypes: {0}", String.Join(",", request.AcceptTypes)); } if (request.Form != null && request.Form.Count > 0) { builder.Append(Environment.NewLine); builder.AppendFormat("Form: {0}", request.Form.ToStringAllValues()); } if (!String.IsNullOrWhiteSpace(request.UserAgent)) { builder.Append(Environment.NewLine); builder.AppendFormat("UserAgent: {0}", request.UserAgent); } if (!String.IsNullOrWhiteSpace(request.HttpMethod)) { builder.Append(Environment.NewLine); builder.AppendFormat("HttpMethod: {0}", request.HttpMethod); } if (!String.IsNullOrWhiteSpace(request.UserHostAddress)) { builder.Append(Environment.NewLine); builder.AppendFormat("UserHostAddress: {0}", request.UserHostAddress); } if (request.UserLanguages != null && request.UserLanguages.Length > 0) { builder.Append(Environment.NewLine); builder.AppendFormat("AcceptTypes: {0}", String.Join(",", request.UserLanguages)); } if (request.UrlReferrer != null) { builder.Append(Environment.NewLine); builder.AppendFormat("UrlReferrer: {0}", request.UrlReferrer); } if (!String.IsNullOrWhiteSpace(request.RawUrl)) { builder.Append(Environment.NewLine); builder.AppendFormat("RawUrl: {0}", request.RawUrl); } Stream inputStream = request.InputStream; if (inputStream != null) { inputStream.Seek(0, System.IO.SeekOrigin.Begin); using (StreamReader reader = new StreamReader(inputStream)) { String body = reader.ReadToEnd(); if (!String.IsNullOrWhiteSpace(body)) { builder.AppendFormat("Body: {0}", body); } } } WebUtility.Trace(builder.ToString()); } }