By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,877 Members | 1,064 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,877 IT Pros & Developers. It's quick & easy.

UNC Directory browser with aspx

P: n/a
Hello,

I am creating an application that uses impersonation to log a user into
our domain and then show them the contents of their network share where
they store their files.

I have all the permissions and impersonation working correctly, Now I
have hit a snag on how to get my idea to work..

Right now i have default.aspx, and Directory.cs

inside Directory.cs is the class DirNavigator which has two public
properties: userPath, Current

userPath = full UNC path to their network share
Current = full path to the folder they are browsing after the userPath

I.E.:
userPath = "\\server\dkode"
Current = "Folder1\Folder2\Folder3

so once they are appended together,
\\server\dkode\Folder1\Folder2\Folder3

each time they browse to a different folder, it appends or subtracts
from Current.

The problem arises from the fact that I am storing dirNavigator
instance in the session, each time default.aspx loads, I show the
appropriate folder. When they click the back button, dirNavigator is
not updated and when they click on a different folder, it still thinks
they are one folder deeper then they are.

How else can I store the instance of dirNavigator so that it updates
itself and always has the current path they are working with. maybe a
hidden form variable? the folders can get pretty deep so I don't want
to pass the whole folder path in the querystring...
any suggestions?

Thank you!

DKode

Nov 19 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
You can either place it as a hidden form variable, but I would recommend
placing the CurrentFolder into viewstate for the page. It is basically the
same as a hidden field, except it isn't a hidden field viewable by View
Source.

Also ViewState, IMO, seems easier to code against.

public string Current
{
get
{
//doing it this way will shield your implementation for checking for
null and empty string.
string s = ( string ) ViewState["Current"];
return ( s == null ) ? String.Empty : s;
}
set { ViewState["Current"] = value; }
}
You reference the item anywhere in a page through the property Current.

HTH,

bill

<dk****@gmail.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
Hello,

I am creating an application that uses impersonation to log a user into
our domain and then show them the contents of their network share where
they store their files.

I have all the permissions and impersonation working correctly, Now I
have hit a snag on how to get my idea to work..

Right now i have default.aspx, and Directory.cs

inside Directory.cs is the class DirNavigator which has two public
properties: userPath, Current

userPath = full UNC path to their network share
Current = full path to the folder they are browsing after the userPath

I.E.:
userPath = "\\server\dkode"
Current = "Folder1\Folder2\Folder3

so once they are appended together,
\\server\dkode\Folder1\Folder2\Folder3

each time they browse to a different folder, it appends or subtracts
from Current.

The problem arises from the fact that I am storing dirNavigator
instance in the session, each time default.aspx loads, I show the
appropriate folder. When they click the back button, dirNavigator is
not updated and when they click on a different folder, it still thinks
they are one folder deeper then they are.

How else can I store the instance of dirNavigator so that it updates
itself and always has the current path they are working with. maybe a
hidden form variable? the folders can get pretty deep so I don't want
to pass the whole folder path in the querystring...
any suggestions?

Thank you!

DKode

Nov 19 '05 #2

P: n/a
thank you,

what does this piece of code here do, i see its some sort of
substitution?

return ( s == null ) ? String.Empty : s;

other than that, would that solve the ie back button problem? or would
i have to format the userpath/current folder?

thanks again

Nov 19 '05 #3

P: n/a
This is shorthand syntax for an if statement. I am not sure if this will
work in vb.

return ( s == null ) ? String.Empty : s;

is equivilent to:

if ( s == null )
return String.Empty;
else
return s;

When the user hits the back button they will be on a page that is displaying
a different path. When the user causes postback on the "backed" page, the
ViewState for the page will have the correct path. I am not sure entirely
what you are asking, but a page that is posted back will have the ViewState
from the page as originally sent. Just try it out and see if that is the
behavior you are expecting and wanting.

bill

"DKode" <dk****@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
thank you,

what does this piece of code here do, i see its some sort of
substitution?

return ( s == null ) ? String.Empty : s;

other than that, would that solve the ie back button problem? or would
i have to format the userpath/current folder?

thanks again

Nov 19 '05 #4

P: n/a
ok,

really dumb question,

when I place the ViewState[] code in my dirNavigator class, it says
ViewState namespace does not exist, I added all the refernces as the
aspx page. Can you access ViewState from outside an aspx page or not?

Nov 19 '05 #5

P: n/a
The ViewState is a protected property of the page. If you want to reference
the viewstate outside the page object, you will need to pass a reference
over to it.

I am not sure of your exactly implementation, but you should change this to
what you need it to do.

public class dirNavigator
{
private readonly StateBag ViewState;
publiv dirNavigator( StateBag viewState )
{
ViewState = viewState;
}
}

Now in your page code you will pass the reference to the constructor of the
class.

//in page load or where ever you instantiate it.
dirNavigator navigator = new dirNavigator( this.ViewState );

You will then be able to access the ViewState collection from your outside
class.

HTH,

bill

"DKode" <dk****@gmail.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
ok,

really dumb question,

when I place the ViewState[] code in my dirNavigator class, it says
ViewState namespace does not exist, I added all the refernces as the
aspx page. Can you access ViewState from outside an aspx page or not?

Nov 19 '05 #6

P: n/a
gotcha,

thanks for the info. i will give it a shot tonight probably.
thanks again!

DKode

Nov 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.