Showing posts with label explain. Show all posts
Showing posts with label explain. Show all posts

Saturday, March 24, 2012

Strange Error - When Subfolder is converted to virutal folder

Let me explain step wise.
1.. I have a site running on port 5555
2.. If contains web.config file with contains <Forms> authentication.
3.. The site contains a sub-folder named "MembersArea" which contains ss.aspx
4.. ss.aspx contains page_load event which prints
Response.Write(Page.User.Identity.Name);
5.. Everything work proper untill here
6.. Now i want to have one more web.config file for folder "MembersArea" , I know i just cannot put web.config file into any sub-folder unless the folder is a "virtual folder"
7.. so i converted the "subfolder" into "virtual folder" from IIS Manager. (Note: I have not yet created any web.config in this subfolder)
8.. Now when i try to execute ss.aspx it throws strange error ... ( you can see the screen dump in the attached file)
9.. The Erorr message is: "Could not load type 'hs.ss'."
10.. When i remove the "virtual folder" it works again.
Can some one tell me what's actuall happening.When you set up another virtual folder, the ASP.NET runtime thinks that you
have an entirely separate ASP.NET application, and any data from the root
application is no longer available to you. In this case, your compiled code
is sitting in the root directory's bin subdirectory, and is not accessible
to the new application that you have created. Just leave it set up to not be
a virtual folder, and you will be fine. Also, you are absolutely able to
override settings in the web.config of your child folders - there are some
settings that are only held at the root level, these settings are inherited,
and you simply override those settings you need modified for a subfolder.
Most commonly, what I do is change access permissions for subfolders in a
child web.config, and leave everything else as the inherited values.

--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

<Jignesh> wrote in message news:OAA5puswDHA.1088@.tk2msftngp13.phx.gbl...
Let me explain step wise.
1.. I have a site running on port 5555
2.. If contains web.config file with contains <Forms> authentication.
3.. The site contains a sub-folder named "MembersArea" which contains
ss.aspx
4.. ss.aspx contains page_load event which prints
Response.Write(Page.User.Identity.Name);
5.. Everything work proper untill here
6.. Now i want to have one more web.config file for folder "MembersArea" ,
I know i just cannot put web.config file into any sub-folder unless the
folder is a "virtual folder"
7.. so i converted the "subfolder" into "virtual folder" from IIS
Manager. (Note: I have not yet created any web.config in this subfolder)
8.. Now when i try to execute ss.aspx it throws strange error ... ( you
can see the screen dump in the attached file)
9.. The Erorr message is: "Could not load type 'hs.ss'."
10.. When i remove the "virtual folder" it works again.
Can some one tell me what's actuall happening.
I have a situation as follows. please suggest what shall i do.
a.. To login into the main site users need passwords. Its simple i have done this using asp.net forms authentication method.
b.. The site has "admin" section. which is to be protected by one more password level. Even if the user tries to access any admin pages directly by typing in url it should ask user "special" password to access pages.
c.. I thought by making it virtual directory i will be able to add web.config file with <authentication> tags for this sub-virtual folder.
But now it seems it will not be possible to do this. can u tell me any other way to implement this?

Regards,

"Chris Jackson" <chrisjATmvpsDOTorgNOSPAM> wrote in message news:%23af0bfywDHA.3116@.tk2msftngp13.phx.gbl...
> When you set up another virtual folder, the ASP.NET runtime thinks that you
> have an entirely separate ASP.NET application, and any data from the root
> application is no longer available to you. In this case, your compiled code
> is sitting in the root directory's bin subdirectory, and is not accessible
> to the new application that you have created. Just leave it set up to not be
> a virtual folder, and you will be fine. Also, you are absolutely able to
> override settings in the web.config of your child folders - there are some
> settings that are only held at the root level, these settings are inherited,
> and you simply override those settings you need modified for a subfolder.
> Most commonly, what I do is change access permissions for subfolders in a
> child web.config, and leave everything else as the inherited values.
>
> --
> Chris Jackson
> Software Engineer
> Microsoft MVP - Windows Client
> Windows XP Associate Expert
> --
> More people read the newsgroups than read my email.
> Reply to the newsgroup for a faster response.
> (Control-G using Outlook Express)
> --
>
> <Jignesh> wrote in message news:OAA5puswDHA.1088@.tk2msftngp13.phx.gbl...
> Let me explain step wise.
> 1.. I have a site running on port 5555
> 2.. If contains web.config file with contains <Forms> authentication.
> 3.. The site contains a sub-folder named "MembersArea" which contains
> ss.aspx
> 4.. ss.aspx contains page_load event which prints
> Response.Write(Page.User.Identity.Name);
> 5.. Everything work proper untill here
> 6.. Now i want to have one more web.config file for folder "MembersArea" ,
> I know i just cannot put web.config file into any sub-folder unless the
> folder is a "virtual folder"
> 7.. so i converted the "subfolder" into "virtual folder" from IIS
> Manager. (Note: I have not yet created any web.config in this subfolder)
> 8.. Now when i try to execute ss.aspx it throws strange error ... ( you
> can see the screen dump in the attached file)
> 9.. The Erorr message is: "Could not load type 'hs.ss'."
> 10.. When i remove the "virtual folder" it works again.
> Can some one tell me what's actuall happening.
>
>

Thursday, March 22, 2012

Strange firing sequence??

Hi all. Can't explain this...
I am using custom control COCA that includes an Image IMAGO. IMAGO raises
the Click event for COCA when clicked. All good so far.
The custom control COCA is created dynamically and lives on a Webform1.
Whenever COCA is clicked, the COCA_Clicked event on Webform1 needs to fire
and return the coordinates values of COCA to a textbox on the form (done via
VB: AddHandler CC1.Click, AddressOf CC1_Clicked).
Here's the confusing part: when CC1 is clicked on the form the first thing
that happens is the page posts back. Only then, CC1_Clicked fires, and
writes value to the textbox. I see CC1_Clicked running by settping through
and the values ARE being written to the textbox but they never actually show
up on the form because they are written after the postback. A second click
causes a postback, writes out the previous values, runs CC1_Clicked... so
the output on the form is always 1 phase behind.
Scratching my head... shouldn't this be the other way around?
Click >> CC1_Clicked fires >> writes values to textbox >> page postback?
The custom control:
- Implements INamingContainer
- adds the ImageButton control in CreateChildControls()
- Overrides the Render method and uses EnsureChildControls()
- Is added to the webform with: Me.FindControl("form1").Controls.Add(CC1)
Any ideas? Suggestions? Corrections?
Thanks. Assaf.Sorry folks: spellchecker out of control.
COCA = CC1
IMAGO = IMG1
"Assaf" <at@.isp.com> wrote in message
news:%23jh5xwwPEHA.648@.TK2MSFTNGP10.phx.gbl...
> Hi all. Can't explain this...
> I am using custom control COCA that includes an Image IMAGO. IMAGO raises
> the Click event for COCA when clicked. All good so far.
> The custom control COCA is created dynamically and lives on a Webform1.
> Whenever COCA is clicked, the COCA_Clicked event on Webform1 needs to fire
> and return the coordinates values of COCA to a textbox on the form (done
via
> VB: AddHandler CC1.Click, AddressOf CC1_Clicked).
> Here's the confusing part: when CC1 is clicked on the form the first thing
> that happens is the page posts back. Only then, CC1_Clicked fires, and
> writes value to the textbox. I see CC1_Clicked running by settping through
> and the values ARE being written to the textbox but they never actually
show
> up on the form because they are written after the postback. A second click
> causes a postback, writes out the previous values, runs CC1_Clicked... so
> the output on the form is always 1 phase behind.
> Scratching my head... shouldn't this be the other way around?
> Click >> CC1_Clicked fires >> writes values to textbox >> page postback?
> The custom control:
> - Implements INamingContainer
> - adds the ImageButton control in CreateChildControls()
> - Overrides the Render method and uses EnsureChildControls()
> - Is added to the webform with: Me.FindControl("form1").Controls.Add(CC1)
> Any ideas? Suggestions? Corrections?
> Thanks. Assaf.
>

Strange firing sequence??

Hi all. Can't explain this...

I am using custom control COCA that includes an Image IMAGO. IMAGO raises
the Click event for COCA when clicked. All good so far.

The custom control COCA is created dynamically and lives on a Webform1.
Whenever COCA is clicked, the COCA_Clicked event on Webform1 needs to fire
and return the coordinates values of COCA to a textbox on the form (done via
VB: AddHandler CC1.Click, AddressOf CC1_Clicked).

Here's the confusing part: when CC1 is clicked on the form the first thing
that happens is the page posts back. Only then, CC1_Clicked fires, and
writes value to the textbox. I see CC1_Clicked running by settping through
and the values ARE being written to the textbox but they never actually show
up on the form because they are written after the postback. A second click
causes a postback, writes out the previous values, runs CC1_Clicked... so
the output on the form is always 1 phase behind.

Scratching my head... shouldn't this be the other way around?
Click >> CC1_Clicked fires >> writes values to textbox >> page postback?

The custom control:
- Implements INamingContainer
- adds the ImageButton control in CreateChildControls()
- Overrides the Render method and uses EnsureChildControls()
- Is added to the webform with: Me.FindControl("form1").Controls.Add(CC1)

Any ideas? Suggestions? Corrections?

Thanks. Assaf.Sorry folks: spellchecker out of control.
COCA = CC1
IMAGO = IMG1

"Assaf" <at@.isp.com> wrote in message
news:%23jh5xwwPEHA.648@.TK2MSFTNGP10.phx.gbl...
> Hi all. Can't explain this...
> I am using custom control COCA that includes an Image IMAGO. IMAGO raises
> the Click event for COCA when clicked. All good so far.
> The custom control COCA is created dynamically and lives on a Webform1.
> Whenever COCA is clicked, the COCA_Clicked event on Webform1 needs to fire
> and return the coordinates values of COCA to a textbox on the form (done
via
> VB: AddHandler CC1.Click, AddressOf CC1_Clicked).
> Here's the confusing part: when CC1 is clicked on the form the first thing
> that happens is the page posts back. Only then, CC1_Clicked fires, and
> writes value to the textbox. I see CC1_Clicked running by settping through
> and the values ARE being written to the textbox but they never actually
show
> up on the form because they are written after the postback. A second click
> causes a postback, writes out the previous values, runs CC1_Clicked... so
> the output on the form is always 1 phase behind.
> Scratching my head... shouldn't this be the other way around?
> Click >> CC1_Clicked fires >> writes values to textbox >> page postback?
> The custom control:
> - Implements INamingContainer
> - adds the ImageButton control in CreateChildControls()
> - Overrides the Render method and uses EnsureChildControls()
> - Is added to the webform with: Me.FindControl("form1").Controls.Add(CC1)
> Any ideas? Suggestions? Corrections?
> Thanks. Assaf.

strange inconsistency referencing controls in Formview itemtemplate

Can anyone explain why in the following code, where btnCancel1 is a
Button inside the itemTemplate of the formview, the first call to
change the text of the button, in the Page_Load sub, works fine, but
the second call, in the bookFormView_ItemUpdated sub, throws an
exception (Object reference not set to an instance of an object)? And
if you know why, can you suggest a workaround?

Here is the code:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
If Not Page.IsPostBack Then
bookFormView.ChangeMode(FormViewMode.ReadOnly)
Dim cancelButton As Button =
CType(bookFormView.FindControl("btnCancel1"), Button)
cancelButton.Text = "Cancel"
End If
End Sub

Protected Sub bookFormView_ItemUpdated(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.FormViewUpdatedEventArgs ) Handles
bookFormView.ItemUpdated
Dim cancelButton1 As Button =
CType(bookFormView.FindControl("btnCancel1"), Button)
cancelButton1.Text = "Done"
End Sub

The line of code where the error occurs is cancelButton1.Text = "Done"

Thanks in advance.

-- NedFollowup: In researching this I came across a comment that only the
controls in the current mode are accessible; if the formview is in edit
mode then only the controls in the <edititemtemplateare accessible,
if in read-only mode then only the controls in the <itemtemplateare
accessible. This might explain this except that an update is supposed
to automatically return the formview to read-only mode, right? Or does
that happen later (after the formview_itemupdated() has terminated)?
So I tried explicitly changing the mode to read-only within the
itemupdated subroutine, but I still get the same error.

Hope someone can relieve my frustration.

-- Ned

Ned Balzer wrote:

Quote:

Originally Posted by

Can anyone explain why in the following code, where btnCancel1 is a
Button inside the itemTemplate of the formview, the first call to
change the text of the button, in the Page_Load sub, works fine, but
the second call, in the bookFormView_ItemUpdated sub, throws an
exception (Object reference not set to an instance of an object)? And
if you know why, can you suggest a workaround?
>
Here is the code:
>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
If Not Page.IsPostBack Then
bookFormView.ChangeMode(FormViewMode.ReadOnly)
Dim cancelButton As Button =
CType(bookFormView.FindControl("btnCancel1"), Button)
cancelButton.Text = "Cancel"
End If
End Sub
>
Protected Sub bookFormView_ItemUpdated(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.FormViewUpdatedEventArgs ) Handles
bookFormView.ItemUpdated
Dim cancelButton1 As Button =
CType(bookFormView.FindControl("btnCancel1"), Button)
cancelButton1.Text = "Done"
End Sub
>
>
>
The line of code where the error occurs is cancelButton1.Text = "Done"
>
Thanks in advance.
>
-- Ned


1) Why not just use the control's variable? If the control has an id of
btnCancel1 and it's marked runat="server", then just do btnCancel1.Text =
"Done"

2) Are you using master pages? Control ID's change when placed into a
content placeholder on a master page. Use the DevToolBar to explore the DOM
and determine what your control's ID actually is on the client size.

"Ned Balzer" wrote:

Quote:

Originally Posted by

Can anyone explain why in the following code, where btnCancel1 is a
Button inside the itemTemplate of the formview, the first call to
change the text of the button, in the Page_Load sub, works fine, but
the second call, in the bookFormView_ItemUpdated sub, throws an
exception (Object reference not set to an instance of an object)? And
if you know why, can you suggest a workaround?
>
Here is the code:
>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
If Not Page.IsPostBack Then
bookFormView.ChangeMode(FormViewMode.ReadOnly)
Dim cancelButton As Button =
CType(bookFormView.FindControl("btnCancel1"), Button)
cancelButton.Text = "Cancel"
End If
End Sub
>
Protected Sub bookFormView_ItemUpdated(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.FormViewUpdatedEventArgs ) Handles
bookFormView.ItemUpdated
Dim cancelButton1 As Button =
CType(bookFormView.FindControl("btnCancel1"), Button)
cancelButton1.Text = "Done"
End Sub
>
>
>
The line of code where the error occurs is cancelButton1.Text = "Done"
>
Thanks in advance.
>
-- Ned
>
>


1) When I try that, I get an error in Visual Web Developer 2005: "Name
'btnCancel1' is not declared." It is marked runat="server" but I think
the problem arises because it is buried within the formview, so it's
not a normal button control.

2) No, I am not currently using master pages.

-- Ned

William Sullivan wrote:

Quote:

Originally Posted by

1) Why not just use the control's variable? If the control has an id of
btnCancel1 and it's marked runat="server", then just do btnCancel1.Text =
"Done"
>
2) Are you using master pages? Control ID's change when placed into a
content placeholder on a master page. Use the DevToolBar to explore the DOM
and determine what your control's ID actually is on the client size.
>
"Ned Balzer" wrote:
>

Quote:

Originally Posted by

Can anyone explain why in the following code, where btnCancel1 is a
Button inside the itemTemplate of the formview, the first call to
change the text of the button, in the Page_Load sub, works fine, but
the second call, in the bookFormView_ItemUpdated sub, throws an
exception (Object reference not set to an instance of an object)? And
if you know why, can you suggest a workaround?

Here is the code:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
If Not Page.IsPostBack Then
bookFormView.ChangeMode(FormViewMode.ReadOnly)
Dim cancelButton As Button =
CType(bookFormView.FindControl("btnCancel1"), Button)
cancelButton.Text = "Cancel"
End If
End Sub

Protected Sub bookFormView_ItemUpdated(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.FormViewUpdatedEventArgs ) Handles
bookFormView.ItemUpdated
Dim cancelButton1 As Button =
CType(bookFormView.FindControl("btnCancel1"), Button)
cancelButton1.Text = "Done"
End Sub

The line of code where the error occurs is cancelButton1.Text = "Done"

Thanks in advance.

-- Ned


Well, it doesn't make sense to me, but I found the suggestion somewhere
and tried it: calling bookformview.databind() before attempting to
reference the object, and the error went away. Problem is, the button
text is not being changed either.

Hmmmmmm

Ned Balzer wrote:

Quote:

Originally Posted by

1) When I try that, I get an error in Visual Web Developer 2005: "Name
'btnCancel1' is not declared." It is marked runat="server" but I think
the problem arises because it is buried within the formview, so it's
not a normal button control.
>
2) No, I am not currently using master pages.
>
-- Ned
>
William Sullivan wrote:

Quote:

Originally Posted by

1) Why not just use the control's variable? If the control has an id of
btnCancel1 and it's marked runat="server", then just do btnCancel1.Text =
"Done"

2) Are you using master pages? Control ID's change when placed into a
content placeholder on a master page. Use the DevToolBar to explore the DOM
and determine what your control's ID actually is on the client size.

"Ned Balzer" wrote:

Quote:

Originally Posted by

Can anyone explain why in the following code, where btnCancel1 is a
Button inside the itemTemplate of the formview, the first call to
change the text of the button, in the Page_Load sub, works fine, but
the second call, in the bookFormView_ItemUpdated sub, throws an
exception (Object reference not set to an instance of an object)? And
if you know why, can you suggest a workaround?
>
Here is the code:
>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
If Not Page.IsPostBack Then
bookFormView.ChangeMode(FormViewMode.ReadOnly)
Dim cancelButton As Button =
CType(bookFormView.FindControl("btnCancel1"), Button)
cancelButton.Text = "Cancel"
End If
End Sub
>
Protected Sub bookFormView_ItemUpdated(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.FormViewUpdatedEventArgs ) Handles
bookFormView.ItemUpdated
Dim cancelButton1 As Button =
CType(bookFormView.FindControl("btnCancel1"), Button)
cancelButton1.Text = "Done"
End Sub
>
>
>
The line of code where the error occurs is cancelButton1.Text = "Done"
>
Thanks in advance.
>
-- Ned
>
>