iOS 8 / Safari 8 not working with ASP.NET AJAX-Extensions

Beware that this solution is only applicable to .NET version < 4.0 So here it is… Working UA: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36 Not working UA: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/600.1.17 (KHTML, like Gecko) Version/7.1 Safari/537.85.10 The problem lies in the major version-change to AppleWebKit/600. ASP.NET … Read more

Web Api Request Content is empty in action filter

The request body is a non-rewindable stream; it can be read only once. The formatter has already read the stream and populated the model. We’re not able to read the stream again in the action filter. You could try: public class LogAttribute : ActionFilterAttribute { public override void OnActionExecuting(HttpActionContext actionContext) { var myModel = actionContext.ActionArguments[“myModel”]; … Read more

Sharing ASP.NET cookies across sub-domains

Set the property of Domain to .mydomain.example in each Cookies of two subdomains websites. Like: Response.Cookies[“test”].Value = “some value”; Response.Cookies[“test”].Domain = “.mysite.example”; In Site A: HttpCookie hc = new HttpCookie(“strName”, “value”); hc.Domain = “.mydomain.example”; // must start with “.” hc.Expires = DateTime.Now.AddMonths(3); HttpContext.Current.Response.Cookies.Add(hc); In Site B: HttpContext.Current.Request.Cookies[“strName”].Value

LINQ to Entities does not recognize the method ‘System.String ToString()’ method in MVC 4

You got this error because Entity Framework does not know how to execute .ToString() method in sql. So you should load the data by using ToList and then translate into SelectListItem as: var query = dba.blob.ToList().Select(c => new SelectListItem { Value = c.id.ToString(), Text = c.name_company, Selected = c.id.Equals(3) }); Edit: To make it more … Read more

How to configure SMTP settings in web.config

By setting the values <mailSettings> section of the in the web.config you can just new up an SmtpClient and the client will use those settings. https://learn.microsoft.com/en-us/dotnet/api/system.net.mail.smtpclient.-ctor?view=net-6.0#system-net-mail-smtpclient-ctor Web.Config file: <configuration> <system.net> <mailSettings> <smtp from=”yourmail@gmail.com”> <network host=”smtp.gmail.com” port=”587″ userName=”yourmail@gmail.com” password=”yourpassword” enableSsl=”true”/> </smtp> </mailSettings> </system.net> </configuration> C#: SmtpClient smtpClient = new SmtpClient(); smtpClient.Send(msgMail); However, if authentication is needed, … Read more

tech