ASP.Net VB code does not execute on postback (WebMatrix vs. not)

Discussion in 'ASP .Net' started by Brian Miller, Nov 25, 2004.

  1. Brian Miller

    Brian Miller Guest

    I've been constructing an ASP.Net application using the 1.1 framework,
    and have been using Web Matrix for development purposes. Now that my
    application is near completion, I wanted to see if I can set up my
    pages for access directly via localhost (not using the WebMatrix
    server). My login page loads, and any validation controls on the page
    work fine, so I know it's recognizing the ASP.Net code there, however,
    when I try to log on, the page just reloads with the login fields
    blank. I've put a response.write line into my code to see where it's
    executing, and the line does show when the page loads, confirming
    things are working on initial load, but if I put that write line at
    the beginning of the IsPostBack = True section, it does not show,
    which makes me think the VB code isn't even running on postback at
    all. If I run my app using the WebMatrix server, the PostBack VB code
    does execute, as I can log in successfully and proceed through my
    application (if login fails, there is user notification, to confirm is
    has validated against the database). Is there something that I need
    to do differently to configure IIS to make the folder run the
    application correctly? Below is a streamlined version of my Page_Load
    event. If anyone can provide info on how to make IIS work for this,
    I'd really appreciate it!

    Thanks,
    Brian

    <%@ Page Language="VB" %>
    <%@ import Namespace="System.Data.SQLClient" %>
    <%@ import Namespace="System.Data" %>
    <script runat="server">

    Dim LoginFailed As Boolean

    Sub Page_Load()
    If IsPostBack = True Then
    Dim conPubs As SqlConnection
    Dim strConString As String
    Dim cmdReadUser As SqlCommand
    Dim dtrUser As SqlDataReader
    Dim userRole As String
    Dim SQLString As String
    Dim i As Integer

    'Use the standard connection set in the web.config file
    strConString =
    ConfigurationSettings.AppSettings("ConnectionString")
    conPubs = New SqlConnection(strConString)

    'Validate the user name and password against the database
    SQLString = ...

    cmdReadUser = New SqlCommand(SQLString, conPubs)

    conPubs.Open()
    dtrUser =
    cmdReadUser.ExecuteReader(CommandBehavior.SingleRow)

    'If datareader can be read, there is a record found for
    the user (login success)
    If dtrUser.Read Then
    'Set user role....
    Response.Redirect("Page1.aspx")
    Else
    'Login failed
    LoginFailed = True
    End If
    End If
    End Sub
     
    Brian Miller, Nov 25, 2004
    #1
    1. Advertising

  2. Brian Miller

    Scott Allen Guest

    Brian:

    Make sure the ASP.NET JavaScript files are installed properly. There
    is some script to handle client side events - you might notice IE has
    an error icon in the lower left when things are not working.

    You can install/reinstall the client files with:
    aspnet_regiis -c

    Where aspnet_regiis will be in the framework install directory.

    --
    Scott
    http://www.OdeToCode.com/blogs/scott/

    On 25 Nov 2004 08:47:10 -0800, (Brian Miller)
    wrote:

    >I've been constructing an ASP.Net application using the 1.1 framework,
    >and have been using Web Matrix for development purposes. Now that my
    >application is near completion, I wanted to see if I can set up my
    >pages for access directly via localhost (not using the WebMatrix
    >server). My login page loads, and any validation controls on the page
    >work fine, so I know it's recognizing the ASP.Net code there, however,
    >when I try to log on, the page just reloads with the login fields
    >blank. I've put a response.write line into my code to see where it's
    >executing, and the line does show when the page loads, confirming
    >things are working on initial load, but if I put that write line at
    >the beginning of the IsPostBack = True section, it does not show,
    >which makes me think the VB code isn't even running on postback at
    >all. If I run my app using the WebMatrix server, the PostBack VB code
    >does execute, as I can log in successfully and proceed through my
    >application (if login fails, there is user notification, to confirm is
    >has validated against the database). Is there something that I need
    >to do differently to configure IIS to make the folder run the
    >application correctly? Below is a streamlined version of my Page_Load
    >event. If anyone can provide info on how to make IIS work for this,
    >I'd really appreciate it!
    >
    >Thanks,
    >Brian
    >
    ><%@ Page Language="VB" %>
    ><%@ import Namespace="System.Data.SQLClient" %>
    ><%@ import Namespace="System.Data" %>
    ><script runat="server">
    >
    > Dim LoginFailed As Boolean
    >
    > Sub Page_Load()
    > If IsPostBack = True Then
    > Dim conPubs As SqlConnection
    > Dim strConString As String
    > Dim cmdReadUser As SqlCommand
    > Dim dtrUser As SqlDataReader
    > Dim userRole As String
    > Dim SQLString As String
    > Dim i As Integer
    >
    > 'Use the standard connection set in the web.config file
    > strConString =
    >ConfigurationSettings.AppSettings("ConnectionString")
    > conPubs = New SqlConnection(strConString)
    >
    > 'Validate the user name and password against the database
    > SQLString = ...
    >
    > cmdReadUser = New SqlCommand(SQLString, conPubs)
    >
    > conPubs.Open()
    > dtrUser =
    >cmdReadUser.ExecuteReader(CommandBehavior.SingleRow)
    >
    > 'If datareader can be read, there is a record found for
    >the user (login success)
    > If dtrUser.Read Then
    > 'Set user role....
    > Response.Redirect("Page1.aspx")
    > Else
    > 'Login failed
    > LoginFailed = True
    > End If
    > End If
    > End Sub
     
    Scott Allen, Nov 25, 2004
    #2
    1. Advertising

  3. Brian Miller

    Brian Miller Guest

    Scott,
    Thanks for the reply. I'm not getting any script errors on my end,
    but did run the command just to be sure that things are installed
    here. Still the same issue of the page resubmitting to itself and
    clearing out. Just for kicks, I tried opening a few different pages
    of my application directly so I could make sure it's not just the
    logon page that's doing this. The same thing seems to happen on all
    pages...you can type in data, validation, and all other controls on
    the page seem to load properly (HTML output from ASP.Net looks good),
    but the page just clears when you try to submit the page, as if
    postback is being ignored altogether. I also tried setting up an
    ASPNET user account for the folder in IIS, as I'd seen messages on
    that before, but that also did not help. Any other thoughts as to the
    cause of this issue?

    Thanks again,
    Brian

    Scott Allen <bitmask@[nospam].fred.net> wrote in message news:<>...
    > Brian:
    >
    > Make sure the ASP.NET JavaScript files are installed properly. There
    > is some script to handle client side events - you might notice IE has
    > an error icon in the lower left when things are not working.
    >
    > You can install/reinstall the client files with:
    > aspnet_regiis -c
    >
    > Where aspnet_regiis will be in the framework install directory.
    >
    > --
    > Scott
    > http://www.OdeToCode.com/blogs/scott/
    >
    > On 25 Nov 2004 08:47:10 -0800, (Brian Miller)
    > wrote:
    >
    > >I've been constructing an ASP.Net application using the 1.1 framework,
    > >and have been using Web Matrix for development purposes. Now that my
    > >application is near completion, I wanted to see if I can set up my
    > >pages for access directly via localhost (not using the WebMatrix
    > >server). My login page loads, and any validation controls on the page
    > >work fine, so I know it's recognizing the ASP.Net code there, however,
    > >when I try to log on, the page just reloads with the login fields
    > >blank. I've put a response.write line into my code to see where it's
    > >executing, and the line does show when the page loads, confirming
    > >things are working on initial load, but if I put that write line at
    > >the beginning of the IsPostBack = True section, it does not show,
    > >which makes me think the VB code isn't even running on postback at
    > >all. If I run my app using the WebMatrix server, the PostBack VB code
    > >does execute, as I can log in successfully and proceed through my
    > >application (if login fails, there is user notification, to confirm is
    > >has validated against the database). Is there something that I need
    > >to do differently to configure IIS to make the folder run the
    > >application correctly? Below is a streamlined version of my Page_Load
    > >event. If anyone can provide info on how to make IIS work for this,
    > >I'd really appreciate it!
    > >
    > >Thanks,
    > >Brian
    > >
    > ><%@ Page Language="VB" %>
    > ><%@ import Namespace="System.Data.SQLClient" %>
    > ><%@ import Namespace="System.Data" %>
    > ><script runat="server">
    > >
    > > Dim LoginFailed As Boolean
    > >
    > > Sub Page_Load()
    > > If IsPostBack = True Then
    > > Dim conPubs As SqlConnection
    > > Dim strConString As String
    > > Dim cmdReadUser As SqlCommand
    > > Dim dtrUser As SqlDataReader
    > > Dim userRole As String
    > > Dim SQLString As String
    > > Dim i As Integer
    > >
    > > 'Use the standard connection set in the web.config file
    > > strConString =
    > >ConfigurationSettings.AppSettings("ConnectionString")
    > > conPubs = New SqlConnection(strConString)
    > >
    > > 'Validate the user name and password against the database
    > > SQLString = ...
    > >
    > > cmdReadUser = New SqlCommand(SQLString, conPubs)
    > >
    > > conPubs.Open()
    > > dtrUser =
    > >cmdReadUser.ExecuteReader(CommandBehavior.SingleRow)
    > >
    > > 'If datareader can be read, there is a record found for
    > >the user (login success)
    > > If dtrUser.Read Then
    > > 'Set user role....
    > > Response.Redirect("Page1.aspx")
    > > Else
    > > 'Login failed
    > > LoginFailed = True
    > > End If
    > > End If
    > > End Sub
     
    Brian Miller, Nov 26, 2004
    #3
  4. Did u install the new .Net?
    Try updating ur asp_client folder.
    Patrick



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Patrick Olurotimi Ige, Nov 26, 2004
    #4
  5. Brian Miller

    Brian Miller Guest

    I have the 1.1 framework installed, if that's what you mean. I know
    there's a 2.0 beta out there, but don't want to use that until the
    official release. As for the asp_client folder, what settings need
    changed there, as opposed to my application folder?

    Thanks,
    Brian

    Patrick Olurotimi Ige <> wrote in message news:<>...
    > Did u install the new .Net?
    > Try updating ur asp_client folder.
    > Patrick
    >
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Brian Miller, Nov 26, 2004
    #5
  6. Have u installed/reinstalled the client files with:
    aspnet_regiis -c as scott suggested?
    What i thought about again is that how did u create your virtual
    directory ?
    Did u create it manually using the IIS wizard?
    Or did u just create the folder under the WWWROOT.
    Becos its best to have it created as an application
    in IIS.
    Are u using ASP.net web matrix server to run the application?
    Patrick

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Patrick Olurotimi Ige, Nov 27, 2004
    #6
  7. Brian Miller

    Brian Miller Guest

    I did do the reinstall using that command line as suggested, with no
    change. I originally created the folder in Windows Explorer, but to
    test here a minute ago, I deleted it, then set up the folder using the
    wizard as you said. What default settings should I have to the folder
    so that it works? I created the folder with the default
    configuration, and it still just refreshes the page with cleared data
    when I try to postback to the page. Should it just be read and run
    privileges which are the defaults when you run the wizard, and are
    there any other settings I would need to change? Please let me know
    what settings I should have for Virtual Directory, as well as the
    other tabs in IIS for properties to verify I have this right.

    I have basically been using the Web Matrix server instead of IIS,
    since it would not allow me to run the server. I'm on a timeline with
    this project, so I needed to use whatever I could to at least see my
    code in action (my site works great when I run the Web Matrix server
    for this directory). It's when I shut down Web Matrix, and try to run
    the site via IIS is where it has this page postback issue.

    Please let me know about the settings, and thanks for your reply!

    Brian

    Patrick Olurotimi Ige <> wrote in message news:<>...
    > Have u installed/reinstalled the client files with:
    > aspnet_regiis -c as scott suggested?
    > What i thought about again is that how did u create your virtual
    > directory ?
    > Did u create it manually using the IIS wizard?
    > Or did u just create the folder under the WWWROOT.
    > Becos its best to have it created as an application
    > in IIS.
    > Are u using ASP.net web matrix server to run the application?
    > Patrick
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Brian Miller, Nov 27, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RGF2aWQ=?=

    Webmatrix: Wizard's UPDATE code does nothing?

    =?Utf-8?B?RGF2aWQ=?=, Sep 15, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    415
    =?Utf-8?B?RGF2aWQ=?=
    Sep 15, 2004
  2. nicholas

    WebMatrix changes the code

    nicholas, Oct 6, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    374
    Patrick.O.Ige
    Oct 6, 2004
  3. Guest

    Webmatrix advice vs VS.net

    Guest, Dec 1, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    584
    Guest
    Dec 2, 2004
  4. checoo
    Replies:
    0
    Views:
    323
    checoo
    Jan 11, 2007
  5. Mark Hammond

    How does WebMatrix work?

    Mark Hammond, Jan 23, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    139
    Mark Hammond
    Jan 23, 2004
Loading...

Share This Page