0

We are in the process of creating a website for a business on the ASP.NET 4.0 framework and IIS 6.0 - must hold the best pattern and practices.

Issue:

We need to access network directories in our business logic layer.

Clarification:

We have a business logic layer built into a separate project. How would we need to access the network directory content? Is that directly (\XYZ123\folder\folder\file.xml) or through IIS?

If it is through the IIS, how to access the virtual directory mapped network directory - The Server.MapPath() can't be used in the business logic project, because it belongs to the Page!

Let me know for other better options as well, Thank you,

  • Well, right off the bat you aren't following best "pattern and practices". Get rid of IIS 6, that's on 2003 server, which is ancient and unsupported. Move to 2008 R2 at the least or 2012. – NotMe Apr 04 '13 at 02:33
  • The IIS would be be eventually update. – user2242951 Apr 04 '13 at 03:10

2 Answers2

0

The UI layer can use Server.MapPath() to send the absolute path of the file to the business logic.

Ketan
  • 5,861
  • 3
  • 32
  • 39
  • When I already know the Physical Path (the network location at the business logic layer), using that via the IIS and Server.MapPath - What significance does it holds? – user2242951 Apr 04 '13 at 03:09
  • So your concern is actually accessing the file from which layer? if so, business layer or data layer is OK too. Since file I/O is a type of data access, the data layer is the best place to put it. As long as it is on a separate interface that can be mocked / stubbed for testing you are ok. – Ketan Apr 04 '13 at 03:51
0

Please check out this thread: httpcontext.current.server.mappath Object reference not set to an instance of an object

I have used system.web.httpcontext.current.mappath() from a library, so long as it is being used by your web application it should work (you may need to add a reference to system.web to your project). I've not used the httpruntime solution they are recommending, but it looks promising as well. good luck.

Community
  • 1
  • 1
mikey
  • 5,090
  • 3
  • 24
  • 27