Web Forms :: Accessing Files On A Mapped Server?

Oct 12, 2010

I have file locations stored in my DB. The locations are mapped drives on a different server. How can I access them? Do I need to set something up in IIS?

Here are som example locations:

\FILESERVERP4W$Documents - FCClient�0510911000LE~1.DOC
V:471471231File Note 28.11.08.1.doc

View 11 Replies


Similar Messages:

Networking - Accessing Mapped Drives When Impersonating?

Apr 19, 2010

Short Version: Can anyone say whether it's possible or not to use impersonation in ASP.NET to access mapped drives?

Long Version:
I'm currently using impersonation in ASP.NET to gain access to network files. This is working perfectly for any network file using a UNC path, but it is failing to access any files on mapped drives defined for the user account I'm impersonating.

For example, let's say a file lives on the network at "machinefolderfile.txt", and let's also say that drive S: is mapped to "machinefolder". We need to be able to access both the full UNC path, "machinefolderfile.txt", as well as the shorter, mapped drive path, "S:file.txt".

Obviously the standard ASP.NET process cannot access either.

Using a console application that runs under the local account with the mapped S: drive, calling File.Exists(@"machinefolderfile.txt") returns true, and File.Exists(@"S:file.txt") also returns true.

However, when impersonating in an ASP.NET context with the same local account, only File.Exists(@"machinefolderfile.txt") returns true. File.Exists(@"S:file.txt") returns false.

I'm testing with IIS 7 running on my local Windows 7 Professional box, though this will need to run in both IIS 6 and IIS 7.

Impersonation is handled with a couple of classes in C# which I'll include here:

public static class Impersonation
{
private static WindowsImpersonationContext context;
public static void ImpersonateUser(string username, string password)
{
ImpersonateUser(".", username, password);
}
public static void ImpersonateUser(string domain, string username, string password)
{
StopImpersonating();
IntPtr userToken;
var returnValue = ImpersonationImports.LogonUser(username, domain, password,
ImpersonationImports.LOGON32_LOGON_INTERACTIVE,
ImpersonationImports.LOGON32_PROVIDER_DEFAULT,
out userToken);
context = WindowsIdentity.Impersonate(userToken);
}
public static void StopImpersonating()
{
if (context != null)
{
context.Undo();
context = null;
}
}
}
public static class ImpersonationImports
{
public const int LOGON32_LOGON_INTERACTIVE = 2;
public const int LOGON32_LOGON_NETWORK = 3;
public const int LOGON32_LOGON_BATCH = 4;
public const int LOGON32_LOGON_SERVICE = 5;
public const int LOGON32_LOGON_UNLOCK = 7;
public const int LOGON32_LOGON_NETWORK_CLEARTEXT = 8;
public const int LOGON32_LOGON_NEW_CREDENTIALS = 9;
public const int LOGON32_PROVIDER_DEFAULT = 0;
[DllImport("advapi32.dll", SetLastError = true)]
public static extern int LogonUser(
string lpszUsername,
string lpszDomain,
string lpszPassword,
int dwLogonType,
int dwLogonProvider,
out IntPtr phToken
);
[DllImport("advapi32.dll", SetLastError = true)]
public static extern int ImpersonateLoggedOnUser(
IntPtr hToken
);
[DllImport("advapi32.dll", SetLastError = true)]
public static extern int RevertToSelf();
[DllImport("kernel32.dll", SetLastError = true)]
public static extern int CloseHandle(IntPtr hObject);
}

Then, during Page_Load, we basically do something like this:

Impersonation.ImpersonateUser("DOMAIN", "username", "password");

if (!File.Exists(@"S:file.txt"))
throw new WeCannotContinueException();

I realize using mapped drives isn't a best practice, but for legacy reasons it's desirable for our business. Can anyone say whether it's possible or not to use impersonation in ASP.NET to access mapped drives?

View 2 Replies

How To Upload Files In Mapped Drive

Apr 4, 2011

Need to upload files in mapped drive. i tried with UNC path. locally i tried with 2 systems its working fine. but in production environment its not working. Scenario is, 2 systems with windows 2003 server. one is app server and second is data server. Hosted app in IIS. Its something with the drive/folder permissions.

View 1 Replies

Could Not Upload Files To Mapped Network Drives

Jan 7, 2010

I have created an application to upload files to a mapped network drive(say: Z:), but is showing the error:

System.IO.DirectoryNotFoundException: Could not find a part of the path 'Z'.

What i did:

Created a web page with FileUpload control & a button.In button click event i have used the code as below.

[Code]....

View 9 Replies

HttpHandlers / Modules :: Files Won't Download From Website When The Site Has A Custom HTTP Handler Mapped

Nov 28, 2010

When I have a HttpHandler class in C#/ASP.NET mapped to a file extension in IIS any file with that extension fails to download/display in web browsers (it's downloaded as a 0-byte file in some browsers and nothing at all in other browsers). After removing the application mapping for the HttpHandler in IIS so it doesn't call the IHttpHandler class in C#, the web browser downloads the file successfully.

This was tested with an IHttpHandler class in C# that has an empty ProcessRequest method.

View 2 Replies

HttpHandlers / Modules :: Accessing Files On Another Server Using Httphandler?

Oct 29, 2010

I need to access image files (.jpg) on a server other than the web server my app runs on. I would like to use an httphandler to do this but I am unsure of the syntax to specify the path. I have tried mapping a drive on the web server to the file server but that didn't work. I have tried using a UNC path but that did not work either.

View 1 Replies

Accessing Files On SD Card?

Nov 22, 2010

I have an application where I need to be able to load files from an SDCard inserted in a client pc and have the files loaded to the server. I had the processing working just fine when I was executing it locally, but when I try to run it on a server, of course it would not work, since the card was not available to the server.

I found some info on some of the forums about sharing the card on the client and then mapping the share on the server. I did this, but for some reason, I cannot see the mapped drive. I tried several variatioins of the DriveInfo.GetDrives method and while it shows the drives that are local, it does not show the network drives.

If there is a better way to do this, I am open to changing my direction.

View 3 Replies

Accessing Merging IIS Extended Log Files?

Oct 18, 2010

I need to access, merge and parse my log files using my asp.net application programmatically. I use shared hosting and as I can see log files are out of the root directory of my website? Is there anyway to access those files from my application?

View 1 Replies

Accessing Remote Files From Web Service?

Jul 15, 2010

My web service needs to open some files located on a remote computer.

From Windows I can do the authentication so I can see those files using the File Explorer.

If I try to open the files from my Web Service while it's running using Visual Studio (ASP.NET Development Server) it also works.

However, if I do everything from IIS it doesn't.In order to find out where is the problem what I did was to run a network sniffer and I found out that when using IIS, the system will try to use the account 'ASPNET' to login into those remote computers which will obviously fail.

However this doesn't happen if I run from the IDE (Using the ASP.NET Development Server)I found out that if I use Impersonation for accessing this it will work, the problem is I need to have the same account names on the computer running IIS so I would rather not to do that.

Why is it working from the ASP.NET Development Server and not from IIS? Is there a way to give full access to the ASPNET account?

View 1 Replies

Accessing Files On A Hosted Site?

Oct 25, 2010

I want to create an asp.net based website. When I create the sit eon my local machine I am uploading pdf files to my file system then accessing the files to view in my website. When I make the site go live how do I translatye this? Can I have files saved somehow with my interenet host? How would I access the files though the internet host on my application?

View 2 Replies

Security :: Accessing Files In Protected Folders?

Jan 29, 2010

When I link to a file in a web folder which is user/password protected on the host, I get a panel requiring me to enter the correct user id and password.

I would like to create a link in my form that provides the id and password without exposing it to the user. How can I do this?

View 2 Replies

Web Forms :: Mapped Path Works Only On Local Machine?

Apr 16, 2010

i have the following code. what i have tried to do is map a path which points to my R:/ - the value 'R:' is stored in my web.config file. this drive is on my server. what i then do is pass the file name and play in an embedded media player in the web browser. when browse the website everything works fine. however, when i browse the website on another PC, i get an error saying it cannot access the file. is this because the second PC i tried the wesbite on doesnt have an R: drive? i wouldnt have thought this was a problem though. is what i am doing wrong? does anyone know why i cant access the file on that drive?

fileName = ConfigurationManager.AppSettings["MappedDrive"] + fileName;

View 6 Replies

C# - Accessing Source Code Generated From ASPX/ASCX Files?

Mar 3, 2010

You've probably noticed that when you debug an error which comes from an ASPX or ASCX file (literally, not from a corresponding code-behind file), ASP.NET displays an error page showing you the source file and the line on which the error occurs. The source file being displayed is automatically generated from parsing the page/control. The question is: how can I see this source file without purposely causing an exception?

I'd love to hear that there is some programmatic way (the complexity doesn't matter) to generate source files (preferrably, .cs) from a series of ASPX/ASCX files.

Example. Consider the following ASPX page (the code-behind file may even be absent):

<%@ Page Language="C#"%>
<%@ Register Assembly="AspxGen" Namespace="AspxGen" TagPrefix="ag" %>
<html>
<head><title>Some Title</title></head>
<body>

[Code]....

d:DevAspxGenAspxGenDefault.aspx(9,80): error CS0103: The name 'ThereIsNoSuchProperty' does not exist in the current context

This means, theoretically I can open the .CS files passed to the compiler (namely, App_Web_sqj3krv3.0.cs and App_Web_sqj3krv3.1.cs) and see what ASP.NET has generated from my ASPX markup. Trying to rephrase the previous question: how can I obtain this file from an arbitrary ASPX file (assuming that the file is correct and hence no info will be given on where to search)?

View 3 Replies

Can Server .html Files Using Razor As If They Were .cshtml Files Without Changing The Extension Of All My Pages

Feb 24, 2011

I manage a large asp.net site which has previously been converted from static html site to asp.net. For several reasons (mainly SEO) we decided not to rename all the files to .aspx back when we originally converted the site. This was very easy to do by simply adding the buildProvider and httpHandler to the web.config.

<buildProviders>
<add extension=".html" type="System.Web.Compilation.PageBuildProvider"/>
</buildProviders>
<httpHandlers>
<add path="*.html" verb="*" type="System.Web.UI.PageHandlerFactory"/>
</httpHandlers>

Now I am upgrading the site to use Asp.net WebPages with Razor cshtml files. I can rename all the files if necessary, and use url rewriting to make the urls stay the same, however it would be much easier if I could just configure the web.config to tell it to parse .html files as if they were .cshtml. I have searched around quite a bit, and could not find anything equivalent to the PageHandlerFactory for razor pages. It appears as though it is just an internal mechanism in the .net 4.0 ISAPI handler.

The site is currently running on Windows 2003 server and IIS 6. We will be upgrading to 2008/IIS 7.5 in the near future, but I'd prefer not to wait for that. Is there any way to get the .html files to be parsed by razor as if they were .cshtml files?

View 2 Replies

Installation :: After Installing Server 2008 The Program Files Disapper With The SQL .MDF Files?

Nov 12, 2010

I am not sure this is the forums but I dont know where to write this and this is an EMERGENCY ::I had windows 2003 server. on C: and I have installed windows 2008 server.I had SQL server installed and all of the database files stored inside c:program filessql server....PROBLEM is that after I installed 2008 server I can see 2 folders of program files one for x86 and the other for 64 bits.

View 2 Replies

Send Form Files To The Server Just To Get Summary Filesize Without Sending The Whole Files?

Dec 24, 2010

I have a form with 10 file inputs. They can contain 10 random files with random sizes. If I send these files to ASP.NET server with this code:

var count = HttpContext.Current.Request.Files.Count;
var TotalSize = 0;
for (int i = 0; i < count; i++ )
{
HttpPostedFile postedFile = HttpContext.Current.Request.Files.Get(i);
TotalSize += postedFile.ContentLength;
}

And as you can see I didn't save the files on the server, will this code just calculate the summary of files without need to receive the whole file from the client (And therefore it would be very fast)?

View 1 Replies

SQL Server :: How To Open Different Types Of Files / Display All The List Of Files In Gridview

Aug 26, 2010

I am trying to open different types of files that I have uploaded on my sql server database. I would like to display all the list of files in Gridview. When user click the link it should open download dialog box and should be able to open its particular applications such as word, excel, browsers etc.

View 3 Replies

Web Forms :: Accessing Server Controls From A Class?

Mar 27, 2010

I have several .aspx pages that all have identical code behind pages.For ease of maintenance,I would like all the aspx pages to share a common code behind page.
To do this I have created a MyCommonClass class,which contains the common code.In the code behind of the .aspx pages, I have:

Partial class MyPage
Inherits MyCommonClass
End Class

But now the controls declared in the .aspx pages are not accessible in MyCommonClass.fix this?

View 6 Replies

Best Way To Find Out To Which Route Url Is Getting Mapped In Mvc?

Jun 6, 2010

is there any way to find out to which route my url is getting mapped in asp.net mvc.

View 2 Replies

Web Forms :: Accessing Properties In Server Side Code?

Sep 30, 2010

i have a <div> named 'mydiv' on a web page and have set it's runat property as <server> so it is visible within

my vb.net server side code.

i can see the mydiv within the server side code.

my question:

how do i adjust the height/style of the <div> withion the vb.net code so that whe the page is posted back the new height/style settings apply. how do i get to the style properties server side?

View 3 Replies

Web Forms :: Accessing HTML Table Back At Server?

Mar 26, 2010

I wanted to know whether this is possible or not. I have a page with a div. I populate div at run time with a HTML table I wanted to access that table to get the data back.

I am trying with ParseControl() method... Not success Yet.

View 2 Replies

Coloring A Map According To Mapped Database Values?

Jul 17, 2010

Coloring a map according to mapped database values?

Question: [URL]
one can see a map of european countries colored according to state debt/deficit. Now I would have already found it useful several times if I was able to do such a thing myself, for example to visualize regional sales data.

Is there any (OpenSource) tool with which I can color a world/continental/reginal map according to colors mapped to values in a database ? Or any tool that can construct a custom map ?

Or if there is no such thing, how would one do such a thing oneselfs ? Get the outlines of countries from somewhere, make everything outside the country outlines transparent, set the coordinates and z-indeces to stack several images over one another, and then replace the base color with the selected color in each image, then merge the result to a single picture ?

View 1 Replies

ADO.NET :: Gen Objects Mapped To Entity Framework?

Dec 6, 2010

I've been tasked to convert our old DAL that have gen objects to possibly the Entity Framework 4.0. We create objects inheriting from our genned objects and have a ton methods our legacy codes uses. Does anyone have an idea or possible solution on how to create an entity framework model that maps to our old genned objects? Or a solution that requires us to modify our legacy code minimally?

View 1 Replies

Migrating From PHP With Links Mapped By GOOGLE?

Nov 29, 2010

I'm migrating my website from PHP to ASP.NET and I have a problem.

All links on my website are mapped by GOOGLE, for example: _http://www.xxxxx.com/news.php?id=4345.

When the new version of Website is online, this mapping will not exist.

The link will change to _http://www.xxxxx.com/news.aspx?id=4345.

View 2 Replies

Web Forms :: Accessing Client-side Table Rows On Server?

Jul 23, 2010

I have a table that the user can add rows to through javascript by clicking on a "add rows button". In each row there are two columns one with a dropdown list and the other a text box. The dropdown list is populated with data through a sub on server side code.I need to be able to insert the data from each row into a table but I'm unable to do this. I clicked on my "add rows button" to add several rows and then did a test to see how many rows the table was returning on the server side and it did not include the five rows I added .. only the header row.If there is a better way to allow users to dynamically add rows to a table and then access the dynamically created table on the server then I'm all ears!

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved