Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Path of file

Path of file

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nettutorialquestion
12 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    KamWaf
    wrote on last edited by
    #1

    My brain is fried, been working on this all day and this doesnt seem too hard: Have 2 servers: S1, S2. S1 has my asp.net app. S2 has some files on it in a [b] shared [/b] Folder. [b] In my asp.net app, I want to get one of the files on S2 and just display it [/b] I found an example and whatever I do, the [b]path fails. I try the path from the command prompt and it works. It just doesnt work in the code. I have also tried IP address AND machine name. No use. I have searched yahoo and google , no use. [/b] This is what I have: Dim filepath As String = "\\\Reports\P1.xls" If Not filepath Is Nothing Then [b] If File.Exists(filepath) Then [/b] ****FAILS HERE, cant find the path ***** What do I need to do???

    C 1 Reply Last reply
    0
    • K KamWaf

      My brain is fried, been working on this all day and this doesnt seem too hard: Have 2 servers: S1, S2. S1 has my asp.net app. S2 has some files on it in a [b] shared [/b] Folder. [b] In my asp.net app, I want to get one of the files on S2 and just display it [/b] I found an example and whatever I do, the [b]path fails. I try the path from the command prompt and it works. It just doesnt work in the code. I have also tried IP address AND machine name. No use. I have searched yahoo and google , no use. [/b] This is what I have: Dim filepath As String = "\\\Reports\P1.xls" If Not filepath Is Nothing Then [b] If File.Exists(filepath) Then [/b] ****FAILS HERE, cant find the path ***** What do I need to do???

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      When you run ASP.NET applications it runs in a different security context to you as a user. Therefore the resources that you have access to are not necessarily the same as the resources as the ASP.NET application. You will have to grant access to the account ASP.NET is using to the share. You can find out the name of the account from IIS - In the properties for the virtual directory, select the Directory Security tab, press the Edit button in the Anonymous Access and Authentication Control group. The dialog will be displaying the account ASP.NET is using for anonymous access. If you have already set up some other authenticaion then this may not be the answer you are looking for. Does this help?


      "If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!

      K 1 Reply Last reply
      0
      • C Colin Angus Mackay

        When you run ASP.NET applications it runs in a different security context to you as a user. Therefore the resources that you have access to are not necessarily the same as the resources as the ASP.NET application. You will have to grant access to the account ASP.NET is using to the share. You can find out the name of the account from IIS - In the properties for the virtual directory, select the Directory Security tab, press the Edit button in the Anonymous Access and Authentication Control group. The dialog will be displaying the account ASP.NET is using for anonymous access. If you have already set up some other authenticaion then this may not be the answer you are looking for. Does this help?


        "If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!

        K Offline
        K Offline
        KamWaf
        wrote on last edited by
        #3

        Thanks for the explanation. I checked that and the account is "IUSER_". What should it be then?? I'm running the asp.net application on my laptop, and checked the IIS on my laptop. The second server is on another machine...

        C 1 Reply Last reply
        0
        • K KamWaf

          Thanks for the explanation. I checked that and the account is "IUSER_". What should it be then?? I'm running the asp.net application on my laptop, and checked the IIS on my laptop. The second server is on another machine...

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          eramgardens wrote: What should it be then?? Unless you have a specific reason for changing it then you should leave it. As I said before you have to grant access of the shared folder to the user that needs to access it. In this case you need to grant access to the "IUSER_" account. As this will be on a separate server you may want to either tell IIS that you will control the password for the account (because the server will need to know about it). Or you can create a totally new account for the ASP.NET application to run as (this is probably a better solution because it won't interfere with any other ASP.NET applications you may have on the same machine that are also using the "IUSER_" account) Does this help?


          "If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!

          K 1 Reply Last reply
          0
          • C Colin Angus Mackay

            eramgardens wrote: What should it be then?? Unless you have a specific reason for changing it then you should leave it. As I said before you have to grant access of the shared folder to the user that needs to access it. In this case you need to grant access to the "IUSER_" account. As this will be on a separate server you may want to either tell IIS that you will control the password for the account (because the server will need to know about it). Or you can create a totally new account for the ASP.NET application to run as (this is probably a better solution because it won't interfere with any other ASP.NET applications you may have on the same machine that are also using the "IUSER_" account) Does this help?


            "If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!

            K Offline
            K Offline
            KamWaf
            wrote on last edited by
            #5

            Thanks so much for your help, but I think I'm kind of confused. And I'm the only developer at work...no one else to help..So i really thank you for your help... 1. I went to the folder to give permission to IUSER_account. I clicked on "sharing" tab. Clicked on "permissions". I see "Everyone" there with "full control". I clicked "Add", Typed "IUSER_machinename" but got an error that it cant find it. 2. "you can create a totally new account for the ASP.NET application"... When I create a new aacount, then this new account needs to have access to that folder..right? On that folder, I see "Everyone", i see myself, my coworker and Administrator under the "security" tab... Again, thanks for your help...

            C 1 Reply Last reply
            0
            • K KamWaf

              Thanks so much for your help, but I think I'm kind of confused. And I'm the only developer at work...no one else to help..So i really thank you for your help... 1. I went to the folder to give permission to IUSER_account. I clicked on "sharing" tab. Clicked on "permissions". I see "Everyone" there with "full control". I clicked "Add", Typed "IUSER_machinename" but got an error that it cant find it. 2. "you can create a totally new account for the ASP.NET application"... When I create a new aacount, then this new account needs to have access to that folder..right? On that folder, I see "Everyone", i see myself, my coworker and Administrator under the "security" tab... Again, thanks for your help...

              C Offline
              C Offline
              Colin Angus Mackay
              wrote on last edited by
              #6

              Does the account exist on both machines? IUSER_laptopname If not you have to make sure the account exists on both machines, or it a domain account (I think you need Active Directory for that - and it can be a real pain setting up ASP.NET to use a domain account, Visual Studio doesn't seem to like it for some reason) I'm guessing if you've set Everyone => Full Control (not really secure, but until it works it is a good point to work from) then the ASP.NET application should be able to use it. However the account needs to exist on both machines. I hope this helps. I don't have access to a network right now, so I cannot test stuff to make sure that I've got all my facts correct.


              "If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!

              K 1 Reply Last reply
              0
              • C Colin Angus Mackay

                Does the account exist on both machines? IUSER_laptopname If not you have to make sure the account exists on both machines, or it a domain account (I think you need Active Directory for that - and it can be a real pain setting up ASP.NET to use a domain account, Visual Studio doesn't seem to like it for some reason) I'm guessing if you've set Everyone => Full Control (not really secure, but until it works it is a good point to work from) then the ASP.NET application should be able to use it. However the account needs to exist on both machines. I hope this helps. I don't have access to a network right now, so I cannot test stuff to make sure that I've got all my facts correct.


                "If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!

                K Offline
                K Offline
                KamWaf
                wrote on last edited by
                #7

                Thanks again for your help... Let me dig deeper with the stuff you gave me. And I will post again... Read something about using "impersonation" as well... impersonating the asp account or something.. let me dig deeper and see what I can do. Thanks again..

                C 1 Reply Last reply
                0
                • K KamWaf

                  Thanks again for your help... Let me dig deeper with the stuff you gave me. And I will post again... Read something about using "impersonation" as well... impersonating the asp account or something.. let me dig deeper and see what I can do. Thanks again..

                  C Offline
                  C Offline
                  Colin Angus Mackay
                  wrote on last edited by
                  #8

                  Impersionation is where you get the ASP.NET application to impersonate a user (usually they will have to go through some sort of login process for this)


                  "If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!

                  K 1 Reply Last reply
                  0
                  • C Colin Angus Mackay

                    Impersionation is where you get the ASP.NET application to impersonate a user (usually they will have to go through some sort of login process for this)


                    "If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!

                    K Offline
                    K Offline
                    KamWaf
                    wrote on last edited by
                    #9

                    Thank you so much for helping me. I found this link: http://www.internet.com/icom_cgi/print/print.cgi?url=http%3A//www.15seconds.com/issue/020312.htm[^] And did the Impersionation. I did create another ASP.Net app. Thanks so much for the idea and it works now.

                    K 1 Reply Last reply
                    0
                    • K KamWaf

                      Thank you so much for helping me. I found this link: http://www.internet.com/icom_cgi/print/print.cgi?url=http%3A//www.15seconds.com/issue/020312.htm[^] And did the Impersionation. I did create another ASP.Net app. Thanks so much for the idea and it works now.

                      K Offline
                      K Offline
                      KamWaf
                      wrote on last edited by
                      #10

                      One more issue. This is a small app, I finished it, works great on my machine. I can open the files in that folder, I'm happy.... ok, i WAS happy... I set up the app on production box, created a website, moved the web.config, unchecked "anonymous access", have Impersonation in the web.config...[b] Everything just like mylaptop [/b] When I go to the URL on the production machine and try to bring up the page, [b]I get a "Enter Network Password" dialog box!!! [/b]. Asks me to enter my userid, pwd, domain. I click cancel and I get : "HTTP 401.2 - Unauthorized: Logon failed due to server configuration Internet Information Services. This is usually caused by a server-side script not sending the proper WWW-Authenticate header field. Using Active Server Pages scripting this is done by using the AddHeader method of the Response object to request that the client use a certain authentication method to access the resource. " What to do?? why??

                      K 1 Reply Last reply
                      0
                      • K KamWaf

                        One more issue. This is a small app, I finished it, works great on my machine. I can open the files in that folder, I'm happy.... ok, i WAS happy... I set up the app on production box, created a website, moved the web.config, unchecked "anonymous access", have Impersonation in the web.config...[b] Everything just like mylaptop [/b] When I go to the URL on the production machine and try to bring up the page, [b]I get a "Enter Network Password" dialog box!!! [/b]. Asks me to enter my userid, pwd, domain. I click cancel and I get : "HTTP 401.2 - Unauthorized: Logon failed due to server configuration Internet Information Services. This is usually caused by a server-side script not sending the proper WWW-Authenticate header field. Using Active Server Pages scripting this is done by using the AddHeader method of the Response object to request that the client use a certain authentication method to access the resource. " What to do?? why??

                        K Offline
                        K Offline
                        KamWaf
                        wrote on last edited by
                        #11

                        why does it work fine on my laptop but on the production machine , I get "enter network password"???

                        K 1 Reply Last reply
                        0
                        • K KamWaf

                          why does it work fine on my laptop but on the production machine , I get "enter network password"???

                          K Offline
                          K Offline
                          KamWaf
                          wrote on last edited by
                          #12

                          The production server is in DMZ and maybe file sharing is blocked... IS there a way to use asp.net and FTP??

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups