user3041439
user3041439

Reputation: 153

Closing C# ASP.Net MVC4 Application with a Close Button

I am going to ask the dumnest question ever. I am creating a C# ASP.Net MVC4 application. I want a button on the index page that will shut the application down and close the browser. How do I do it? I currently have the following code snippet in my Index.cshtml to give a button:

@using (Html.BeginForm("CloseApplication", "Home", FormMethod.Post))
{
    <input id="close" name="closeButton" type="submit" style="width:170px" value="Close Application" />
}

I am going to a CloseApplication ActionResult method in my HomeController.cs which currently looks like:

public ViewResult    CloseApplication()
{
    // Something to do here I think
    return null;
}

What do I do here?

Am I over complicating things?

Many thanks to all of you who contribute regularly and help us out.

Upvotes: 0

Views: 752

Answers (1)

Stephen Byrne
Stephen Byrne

Reputation: 7485

Honestly think you are over-complicating things for yourself.

HTTP is stateless so by the time you have rendered a page onto the client's browser, your connections, etc, should have already been Dispose'd and the instance of the controller that returned the view the client is now looking at should no longer exist. The next request the client makes will spin up a whole other controller instance.

So the user can already "close" their "instance" (from their perspective) of the application by closing their browser - adding a button to do this is kind of pointless IMHO!

Upvotes: 2

Related Questions