Bug 21305 - ASP.NET MVC runtime binder error 500
Summary: ASP.NET MVC runtime binder error 500
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Web (show other bugs)
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-07-14 09:49 UTC by pinggi
Modified: 2014-07-14 11:50 UTC (History)
2 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
01_error_500 (32.32 KB, image/png)
2014-07-14 09:49 UTC, pinggi
Details
02_error_500 (30.01 KB, image/png)
2014-07-14 09:50 UTC, pinggi
Details

Description pinggi 2014-07-14 09:49:34 UTC
Created attachment 7355 [details]
01_error_500

I'm developing ASP.NET MVC site with Xamarin Studio and have a strange problem with a page refreshing.

Here's the steps:

1. Rebuild
2. Run without debugging (pressing ctrl + F5)
3. Page is displayed ok
4. Refreshing the page (pressing F5)
5. Page is displayed ok
6. Refreshing the page (pressing F5)
7. I get an Error 500 (see the attachment: 01_error_500)
6. Refreshing the page (pressing F5)
7. I get an Error 500 (see the attachment: 02_error_500)
8. Every other refresh goes to step 7. Several times happened to me that the page was shown correctly. Strange.
Comment 1 pinggi 2014-07-14 09:50:08 UTC
Created attachment 7356 [details]
02_error_500
Comment 2 pinggi 2014-07-14 09:59:04 UTC
There are also the errors in the Aplication Output after several refreshes of the page:

Adding applications '/:.'...
Registering application:
    Host:          any
    Port:          any
    Virtual path:  /
    Physical path: E:\Web\Web01\Web01\
xsp4
Listening on address: 127.0.0.1
Root directory: E:\Web\Web01\Web01
Listening on port: 80 (non-secure)
Peer unexpectedly closed the connection on write. Closing our end.
System.IO.IOException: Write failure ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine.

  at System.Net.Sockets.Socket.Send (System.Byte[] buf, Int32 offset, Int32 size, SocketFlags flags) [0x0005c] in C:\cygwin\sources\mono\mcs\class\System\System.Net.Sockets\Socket.cs:1847 
  at System.Net.Sockets.NetworkStream.Write (System.Byte[] buffer, Int32 offset, Int32 size) [0x0006e] in C:\cygwin\sources\mono\mcs\class\System\System.Net.Sockets\NetworkStream.cs:421 
  --- End of inner exception stack trace ---
  at System.Net.Sockets.NetworkStream.Write (System.Byte[] buffer, Int32 offset, Int32 size) [0x0008e] in C:\cygwin\sources\mono\mcs\class\System\System.Net.Sockets\NetworkStream.cs:424 
  at Mono.WebServer.XSPWorker.Write (System.Byte[] buffer, Int32 position, Int32 size) [0x00000] in /tmp/monobuild/build/BUILD/xsp-2.10.2/src/Mono.WebServer.XSP/XSPWorker.cs:217 
Peer unexpectedly closed the connection on write. Closing our end.
Comment 3 pinggi 2014-07-14 10:02:25 UTC
They are present when the web page is refreshed very quickly (pressing and holding F5 in the browser). There might be no connection with the Error 500, who knows.
Comment 4 pinggi 2014-07-14 10:27:22 UTC
I investigate it a little more and found out that it is caused by my code.
However still do not know why it behaves like that.

I have HomeController returning view by Index action.
I reference the MyContext object there.

	public class HomeController : Controller
	{
		public ActionResult Index()
		{
			MyContext ctx = ((MvcApplication)this.HttpContext.ApplicationInstance).MyContext;

			// here the ctx is set to instance of MyContext
			// but after 1-2 refreshes of the page
			// the ctx become null
			// why?


			...
		}

	}

The MyContext object is created when the application starts:

	public class MvcApplication : System.Web.HttpApplication
	{
		private MyContext ctx;

		public MyContext MyContext { get { return ctx; } }

		protected void Application_Start()
		{
			ctx = new MyContext();


			...
		}
	}

The question is why the mono runtime set ctx to null after several refreshes of the web page?
Comment 5 pinggi 2014-07-14 10:58:58 UTC
Oh, I am stupid. There are more application objects and Application_Start method is call only for the first one!

Application_Start: MvcApplication=77364809
PageController: MvcApplication=77364809
PageController: MvcApplication=77364809
PageController: MvcApplication=197087390  <-- different MvcApplication with ctx = null

So I moved the code from Application_Start to constructor. Now it is without error, but still pressing and holding F5 causes the errors:

Peer unexpectedly closed the connection on write. Closing our end.
System.IO.IOException: Write failure ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine.

  at System.Net.Sockets.Socket.Send (System.Byte[] buf, Int32 offset, Int32 size, SocketFlags flags) [0x00000] in <filename unknown>:0 
  at System.Net.Sockets.NetworkStream.Write (System.Byte[] buffer, Int32 offset, Int32 size) [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Net.Sockets.NetworkStream.Write (System.Byte[] buffer, Int32 offset, Int32 size) [0x00000] in <filename unknown>:0 
  at Mono.WebServer.XSPWorker.Write (System.Byte[] buffer, Int32 position, Int32 size) [0x00000] in <filename unknown>:0

Note You need to log in before you can comment on or make changes to this bug.