Let me preface this post by saying that I skipped from chapter 11 to chapter 18 because I wanted to deploy my own tests and findings as I go along and possibly redo some of the chapters in the book so I may have missed something along the way. Let me also say that I am really impressed that VWD includes its own ftp transfer utility -- I had been using FileZilla for simple HTML pages in the past.
I have a domain and hosting services from GoDaddy with ASP.Net 2.0/3.5 enabled and the help there is not getting me where I need to be (though I haven't called them since I absolutely loathe the idea of talking on the phone for an hour). I made a simple site with a header, label with some text, a text box (txtPassWord), and a button (btnSubmit). Keep in mind that I have not looked at the chapter on Security so this is a half-hearted attempt at preventing unwanted users from entering the site.
I created a code behind file (VB
) for the default.aspx page. It contains a simple conditional for the click event of btnSubmit which checks for an appropriate password (hardcoded into the logic at this point) and sends a msgBox (I am assuming this runs on the client side) if an incorrect password or nothing is entered into txtPassWord. Pretty straightforward, but I can provide the code if need be. The page works fine on my local machine.
I sent the files to the server at GoDaddy via ftp (using your Try It Out -- Using The Copy Web Site Option in the Copying Your Website section of chapter 18 -- no page number since I use Books 24/7). It is similar to copying to the File System and pretty self explanatory. Everything connected fine and the files were transferred without a hitch.
The HTML rendered fine in a browser (Firefox and IE7), but when I click btnSubmit I get the following error in FireFox:
Server Error in '/inspire' 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.
The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:
1. Add a "Debug=true" directive at the top of the file that generated the error. Example:
<%@ Page Language="C#" Debug="true" %>
2) Add the following section to the configuration file of your application:
Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.
Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.
[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(IWin32Win dow owner, String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, Boolean showHelp) +1799842
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.btnSubmit_Click(Object sender, EventArgs e) +60
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEven t(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746
So I went into the web.config file to fix the problem and found the following entry:
<compilation debug="false" strict="false" explicit="true">
This is default code added into the file and I really have no idea what it does other than perhaps showing the stack trace. I am familiar with using Option Explicit in my VBA code, but I don't know if that is relevant to this directive.
One other thing to point out (I don't know if it even makes a difference) is that this is being deployed to a subdomain I created with my GoDaddy hosting account.
So I guess my questions are:
- What is the purpose of the compilation directive I have shown above other than showing a stack trace in the browser upon throwing an error?
- What settings should I use and where should I place them (I would guess in the web.config file between the <system.web> tags) in order to enable objects like a Message Box on the client side (I assume that is where it is processed).
- Should I avoid using Message Boxes completely?
I am sorry about the lengthy post, but I am hoping it also might help someone else out and, for selfish reasons, will serve as a reference for me in the future. I wanted to include as much detail as possible.