Showing posts with label real. Show all posts
Showing posts with label real. Show all posts

Monday, March 26, 2012

Trouble Loading Code Behind Type

Hello,

I'm a new VS.NET user having the following issue.

I've created a new ASP.NET WEb Forms app and have been doing some basic
things with no real problems.

I have decided that the next thing in the development will be a secured area
of the app.

I have determined the Forms Authentication is the way I am going.

I have created a basic login form and modified the Web.config file in my
app's main virtual directory (where all of my files have hitherto resided).
I got this all working, no problem. When a page was requested, the user was
redirected to the login form as expected and when authenticated the
originally requested page was properly display.

Here is where the problem comes up. The site will be a mix of public and
"auth-required" pages. So this basically means that I do not want the
"main" virtual directory of the app secured.

Here is what I did.

First, I disabled the authentication requirement on the main virtual
directory.

Then I created a new virtual directory (under the main app's virtual
directory) and called it "Secure".

I moved the Login.aspx (my custom login form) into the Secure virutal
directory and created an additional blank page in there as well.

I put a new copy of Web.config in the Secure virtual directory and
configured it up for Forms based authentication.

Here is what I expect to happen.

When a page in the app's main virtual directory is requested it loads
for anyone (this works fine).

When a page is initially requested in the Secure virtual directory the
user should be redirected to the Login form (the redirection occurs as
expected)

Here is the problem: The Login.aspx page pops a run time error
complaining that the code behind type cannot be loaded.
Parser Error Message: Could not load type 'RPG.Login'.
The application is named "RPG"
Here is the @dotnet.itags.org.Page
<%@dotnet.itags.org. Page Language="vb" AutoEventWireup="false"
Codebehind="Login.aspx.vb" Inherits="RPG.Login"%
Note: This was not erroring out when page in question was in the app's main
virtual directory. It only occurs for pages (I have tested a "Hello World"
page in the same virtual directory with the same error.

This seems to be some sort of pathing issue, but with the .aspx file and the
.aspx.vb file in the same folder, I don't get the problem. I've tried
changing the reference in the "Inherits" attribute to things like
RPG.Secure.Login but I'm too new to the environment to understand the
Namespace.Class reference and how it is effected by the location of the
files in question.

TIADo you have a file called "RPG.dll" in the /bin folder in the web application root?
Yes. RPG/bin/RPG.dll exists.

Trouble posting to Database from Drop Down List and Text box

I'm having real trouble posting from the webpage back to a database. This is supposed to be one of the easiest things to do in ASP.NET. I've checked viewstate on all of the controls and at the page level and all are set to true.

When I type in some text information, no other characters but plane text, and hit the submit button the text disappears from the box, the drop downlist returns to default, the subroutine runs and an empty space is submitted to the database.

I've verified that the procedure in my namespace is running correctly by allowing the subroutine in the code behind to trigger the SPROC in the namespace. The 'hardcoded' values are inserted into the database.

I also placed a label.text = textbox.text into the subroutine and it is always set to a blank. Even on page intialization. None the less, I wanted to see if running the subroutine would place text inside of the label and it didn't. If I hard code the label, such as label.text = "stanley" then stanley appears when you click the link button. Thus, I'm sure that the subroutine is running, its appears that the text in the text box is being lost when the page makes a round trip.

Any ideas?

SethLet's see your code.
Be sure that you are wrapping any code that initializes the values textbox and dropdownlist in your Page_Load with a check for IsPostBack:


Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
'Initialize initial values of textbox and dropdownlist here
End If
End Sub

If you don't, each time the page postsback, the controls will be reset back to their initial state, probably blank for the textbox and no selected item for the drop down list. Remember that when the page posts back, Page_Load will run BEFORE any of the web control event handlers.