Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Help with an IIS page and Default.aspx.Vb page please.

DrMartenDrMarten Posts: 748Member
[b][red]This message was edited by DrMarten at 2006-11-23 11:18:36[/red][/b][hr]
Hi I have the following code which runs fine under Visual Studio Pro 2005 on the localhost.
[code]
Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim Result As Integer

Result = MsgBox("Hello", MsgBoxStyle.OkOnly)

End Sub

End Class
[/code]

When i try to run it on IIS server i get the following.>>

Server Error in '/users/e5117204' Application.
--------------------------------------------------------------------------------

Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.

Source Error:


Line 4:
Line 5: Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Line 6: MsgBox("Hello!")
Line 7: End Sub
Line 8: End Class


Source File: E:FTPRootLocalUsere5117204VB-Basedsite1Default.aspx.vb Line: 6

Stack Trace:


[InvalidOperationException: Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.]
System.Windows.Forms.MessageBox.ShowCore(IWin32Window owner, String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, Boolean showHelp) +1801778
System.Windows.Forms.MessageBox.Show(IWin32Window owner, String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options) +26
Microsoft.VisualBasic.Interaction.MsgBox(Object Prompt, MsgBoxStyle Buttons, Object Title) +544
_Default.Button1_Click(Object sender, EventArgs e) in E:FTPRootLocalUsere5117204VB-Basedsite1Default.aspx.vb:6
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210

Any help would be much appreciated as i was hoping to do a web based game on an IIS account if this is possible?



Regards,

Dr M.

Comments

  • PavlinIIPavlinII Posts: 404Member
    : [b][red]This message was edited by DrMarten at 2006-11-23 11:18:36[/red][/b][hr]
    : Hi I have the following code which runs fine under Visual Studio Pro 2005 on the localhost.
    : [code]
    : Partial Class _Default
    : Inherits System.Web.UI.Page
    :
    : Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    :
    : Dim Result As Integer
    :
    : Result = MsgBox("Hello", MsgBoxStyle.OkOnly)
    :
    : End Sub
    :
    : End Class
    : [/code]
    :
    : When i try to run it on IIS server i get the following.>>
    :
    : Server Error in '/users/e5117204' Application.
    : --------------------------------------------------------------------------------
    :
    : Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.
    : Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    :
    : Exception Details: System.InvalidOperationException: Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.
    :
    : Source Error:
    :
    :
    : Line 4:
    : Line 5: Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    : Line 6: MsgBox("Hello!")
    : Line 7: End Sub
    : Line 8: End Class
    :
    :
    : Source File: E:FTPRootLocalUsere5117204VB-Basedsite1Default.aspx.vb Line: 6
    :
    : Stack Trace:
    :
    :
    : [InvalidOperationException: Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.]
    : System.Windows.Forms.MessageBox.ShowCore(IWin32Window owner, String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, Boolean showHelp) +1801778
    : System.Windows.Forms.MessageBox.Show(IWin32Window owner, String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options) +26
    : Microsoft.VisualBasic.Interaction.MsgBox(Object Prompt, MsgBoxStyle Buttons, Object Title) +544
    : _Default.Button1_Click(Object sender, EventArgs e) in E:FTPRootLocalUsere5117204VB-Basedsite1Default.aspx.vb:6
    : System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
    : System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
    : System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
    : System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
    : System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
    : System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
    :
    :
    :
    :
    : --------------------------------------------------------------------------------
    : Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210
    :
    : Any help would be much appreciated as i was hoping to do a web based game on an IIS account if this is possible?
    :
    :
    :
    : Regards,
    :
    : Dr M.
    :
    Hi,
    you can NOT show message box on ASP.NET page :)
    Imagine this situation:
    client is logged over putty to some unix-like server in text mode and runs some text web browser. Where is your message box supposed to appear? :)

    Take a look into life cycle of webpage. Everything till Page_PreRender (and some later phrases on application level) occurs and runs ONLY on server side. Then, final page is rendered as HTML (or XHTML or anything you forced the page to return) and this HTML is send to client browser. Now, the page is interpreted.

    If you want to force msgbox to appear, register startup script with javascript alert('your message'); inside.

    Put some asp:label (let's say name="lblMsg") on your page and on button1_click set lblMsg.Text="your message"

    After the message appears, take a look into final HTML code in your code. This is what client browser recieves.

    ASP.NET has quite different life cycle than std winform..
    Clicking on that button does not mean that button.click is immediatelly processed. It causes Form.Submit and launches HTTP POST to your server. IIS recognise this and pass to your application. Now, new thread is created and new instance of _Default (or any other class) is created. (So, you've lost your class-level variables! For example), Page_Load occurs (and Page.IsPostBack is now TRUE), then occurs other page events and other events like button.click...
    and so on..

    Don't forget that between 1st call to your page (type url into browser and get empty page) and clicking that button may pass serveral minutes, hours, days.. During one hour, there may exist completely different world of your application! Database has changed, somebody else could delete the record that your page is trying to modify, file you were viewing no longer exists or somebody else made changes to it and so on..

    When you'll be watching page lifecycle, take a look into ViewState as well..

    Hope this helps

    [blue][b][italic][size=4]P[/size]avlin [size=4]II[/italic][/size][/b][/blue]

    [purple]Don't take life too seriously anyway you won't escape alive from it![/purple]


  • DrMartenDrMarten Posts: 748Member
    Hi,

    This part of the error message [b][blue]"Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.] "[/blue][/b] seems to indicate being able to set the defaultDesktopOnly?

    Otherwise what is the point then of Microsoft making certain controls available in Visual Studio if you can't run the associated code in web design within Visual Studio for an aspx page?

    If you wanted to do a web-site based game then, what scripting languages or other can you use please?
    Would this have to be on a standard server folder that is not an IIS account too please?

    Do you know if all scripting languages can be mixed into one page or just certain ones please?

    Sorry for all the questions.


    Regards,

    Dr M.

  • PavlinIIPavlinII Posts: 404Member
    Hi,
    I've added my comments into text..

    : Hi,
    :
    : This part of the error message [b][blue]"Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.] "[/blue][/b] seems to indicate being able to set the defaultDesktopOnly?

    There's also this part:
    [blue]Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation.[/blue].

    Do not forget, that your're building WEB application. It means, there's webbrowser sending HTTP POST or HTTP GET to your server, and you're generating response for this client (also on HTTP layer.)
    And this communication is PASSIVE! It means, client (resp. webbrowser) sends request and recieves your response (html page, mostly). And that's all you can. React to request. You cannot initiate communication, can not send anything after the response ends. (For example, send some message after 5 minutes timeout.)

    Your application is running on server machine (not client's), and that is the computer you control.. If you need "reports", use database or file logs.. In old ASP application, when you use MsgBox, this message appeared on current server. Just imagine how many msgbox saw someone who connected to the server via remote desktop :) I would not like to click that OKs :)

    There's no user interface, your input is HttpRequest (and .InputStream), output are your resources (like hdd, database etc..) and HttpResponse (resp .OutputStream).

    :
    : Otherwise what is the point then of Microsoft making certain controls available in Visual Studio if you can't run the associated code in web design within Visual Studio for an aspx page?
    :

    You just can not use WinForms-designed controls in web application, and you cannot use web-designed controls in WinForm application.
    Life cycle, context and method significantly differs..

    In winforms, button has it's instance (with private variables etc) aviable during whole application run (until destroying it's container, of course :) ).
    In web page, button is created just for certain request (and is generated from aspx: ). It's created before Page.Load, and destroyed after Page.Prerender (or somewhen like that).. And it's rendered as .. No instance is provided to client, just html representation.
    Only one place, where button and other contols can persist it's state is ViewState (or ControlState in .NET 2.0), but this is rendered as hidden input type to http response, and decoded in next request..

    : If you wanted to do a web-site based game then, what scripting languages or other can you use please?
    : Would this have to be on a standard server folder that is not an IIS account too please?
    :

    You can use any client stripting language, but use Javascript for this.. (There's nothing better yet, unfortunatelly).
    But if you want to build game.. there's lot of techniques, how your game could be realised.
    If it's some kind of interactive game, you should use flash for example.. Because you will not be able to do this in aspx page.
    There's more possibilities, for example java applets, but I do NOT suggest you to use them ;)
    If it's chess-like, adventure-like etc game, use postback technique of aspx page for this.. (clasic request-response..)

    I'm afraid you'll need IIS on your server, because you have to create "Web Application".

    : Do you know if all scripting languages can be mixed into one page or just certain ones please?
    :

    You can use more scripting languages in one web page (javascript, vbscript).. As far as webbrowser can interpret them.. But you have to make separate block for them ;)
    Just use javascript..


    : Sorry for all the questions.
    :
    :
    : Regards,
    :
    : Dr M.
    :
    :

    Web page life cycle overview
    http://msdn2.microsoft.com/en-us/ms178472.aspx

    Event overview - also very different from WinForms because of Request-Response model
    http://msdn2.microsoft.com/en-us/library/y3bwdsh3.aspx

    [blue][b][italic][size=4]P[/size]avlin [size=4]II[/italic][/size][/b][/blue]

    [purple]Don't take life too seriously anyway you won't escape alive from it![/purple]


Sign In or Register to comment.