2

I've an application developed in Asp.NET MVC, and I'm using the Framework Postal MVC, that is used to send Views as E-mail.

It was working properly, without problem, however, today, started to show me the following message:

The virtual path '/' maps to another application, which is not allowed.

It happens only when I try to use SendAsync (async method to send e-mail), however, it was working before without problem. Furthermore, if I use Send (sync method to send e-mail) it work.

I didn't change anything on the Properties, code, etc.

The most important thing that I've done that I remember, was to Publish the application, but, in the code or configuration, I didn't change nothing more.

It looks like that is losing the HttpContext when doing Async.

-- The Async method started to work again when I added the following parameter in my Web.config:

<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
Guffa
  • 687,336
  • 108
  • 737
  • 1,005
Dan
  • 1,518
  • 5
  • 20
  • 48
  • Code doesn't spontaneously break, *something* changed, whether you did it or your web admin did, code doesn't work for a while then rust and stop working... – Ron Beyer Oct 30 '15 at 19:13
  • @RonBeyer it happened in my development ambient, and I was publishing it to put in production ambient. – Dan Oct 30 '15 at 19:16
  • you mean `development environment && Production environment` never ever heard the term `ambient` used in regards to environments also I have seen this issue before when copying a project over and not setting up the virtual directory and or creating one in the target environment if the environments are on the same machine which I hope that's not your case.. what happens when you right click the project and hit properties under `Web --> Project URL` what does your URL look like there is also a Create Virtual Directory button their too.. – MethodMan Oct 30 '15 at 19:27
  • also try putting the following infront of the forward slash `~/` – MethodMan Oct 30 '15 at 19:41
  • @MethodMan you are right, is environment, not ambient. About the URL, it's http://localhost:58893/ and also there is a Create Virtual Directory button – Dan Oct 30 '15 at 19:51
  • It looks like that is losing the HttpContext when doing Async. – Dan Oct 30 '15 at 20:31

1 Answers1

0

Likewise it was working for me as well and all of a sudden I started getting that error on async AJAX methods. So apparently I was copying out the entire folder which is wrong ... but it worked for weeks on end because prior to that, it was deployed correctly (using the Publish method). But somehow it started realising I wasn't publishing (I think I changed many times in a short period of time) and started showing the error.

The fix was to simply deploy correctly using the Publish method. After that it works without the web.config fix mentioned above for aspnet:UseTaskFriendlySynchronizationContext (which goes under <appsettings>).

goamn
  • 1,939
  • 2
  • 23
  • 39