locked
Accessing class file in App_Code RRS feed

  • Question

  • User-13122567 posted

    While working on my FTP server, I am trying to access a class within my App_Code, but it is not working.

    When writing, the class is accessible/usable in the code like shown in picture. I get no build errors.



    But when I run it in the browser, I get an error stating that it cannot find my class.



    I've looked around some other posts on the forum, like using namespace, but it didn't work. Would anyone know how to fix this?

    Thursday, July 1, 2010 12:38 PM

Answers

  • User154448021 posted

    Yes, I believe site.com is independent of the App_Code folder.

    How would I reference the App_Code from site.com application?


     

    I would create a solution with Visual Studio and include both site.com and App_Code in it.  Under site.com, you should see Reference in the solution explorer.  Right click on Reference and choose Add Reference, which will open another window.  Click the project tab, you should see App_Code.  Select App_Code and click ok to close the window. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 1, 2010 2:41 PM
  • User-13122567 posted

    I tried your solution, but the Project tab had no entries.


    <strike>Ok, I managed to solve my problem by moving my App_Code folder into the wwwroot folder - which doesn't seem right. Now, any class from the App_Code is not recognized - but when I run it, it works. Is this unusual? </strike>


    Heh, I just understood why. From Visual Studio, I was accessing my FTP account from the top root, rather than

    ftp://00.000.00.00/site.com/wwwroot. Nevertheless, thanks for your help!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, July 3, 2010 1:06 AM

All replies

  • User154448021 posted

    if site.com is considered as the root of your application, the app_code folder would not be accesible.   

    I would check the applicaton on IIS.

    Thursday, July 1, 2010 12:50 PM
  • User-589915301 posted

    Hi,

    Can you please provide your piece of code.


    Thursday, July 1, 2010 12:56 PM
  • User-13122567 posted

    Thanks for the reply.I am not really tech savvy.

    Do you mean copying the website to my local IIS?

    Thursday, July 1, 2010 1:03 PM
  • User-13122567 posted

    Thanks for the reply as well. Which piece of code exactly?


    Thursday, July 1, 2010 1:04 PM
  • User154448021 posted

    Thanks for the reply.I am not really tech savvy.

    Do you mean copying the website to my local IIS?

     

    No.  What I meant is you should check if your site.com is treated as an application that is independent of the App_Code folder.   If that's the case, you need to reference the App_Code from site.com application.

    Thursday, July 1, 2010 1:09 PM
  • User-13122567 posted

    Yes, I believe site.com is independent of the App_Code folder.

    How would I reference the App_Code from site.com application?


    Thursday, July 1, 2010 2:31 PM
  • User154448021 posted

    Yes, I believe site.com is independent of the App_Code folder.

    How would I reference the App_Code from site.com application?


     

    I would create a solution with Visual Studio and include both site.com and App_Code in it.  Under site.com, you should see Reference in the solution explorer.  Right click on Reference and choose Add Reference, which will open another window.  Click the project tab, you should see App_Code.  Select App_Code and click ok to close the window. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 1, 2010 2:41 PM
  • User-13122567 posted

    I tried your solution, but the Project tab had no entries.


    <strike>Ok, I managed to solve my problem by moving my App_Code folder into the wwwroot folder - which doesn't seem right. Now, any class from the App_Code is not recognized - but when I run it, it works. Is this unusual? </strike>


    Heh, I just understood why. From Visual Studio, I was accessing my FTP account from the top root, rather than

    ftp://00.000.00.00/site.com/wwwroot. Nevertheless, thanks for your help!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, July 3, 2010 1:06 AM