Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Henrik Sunesen 84 posts 281 karma points
    Mar 07, 2019 @ 17:41
    Henrik Sunesen
    0

    App_code required when website in on server?

    Hello,

    I got some issues after going from localhost to server. (mails won't sent and so on). I have another site online that doesn't have these problems, and i have now used lige 1 week to find out what the problem is.

    The online difference in the folder structure in these two sites is that the one that works perfectly has all it's controllers in the app_code folder, and the one that doesn't work has all the controllers in a folder called "Controllers".

    Can that be the problem?

    When i try to make a app_code folder in the project that doesn't have it, it gives me some errors with my tryparse:

     'out variable declaration' is not available in C# 6. Please use language version 7.0 or greater.
    

    I'm running umbraco 7.13.1

    You can see a screenshot of the folder structure here: enter image description here

    Hope someone has the solution for this problem

  • Henrik Sunesen 84 posts 281 karma points
    Mar 08, 2019 @ 07:27
    Henrik Sunesen
    0

    If i copy all the controllers in an app_code folder i get this error:

    umbraco route names must be unique. parameter name: name

  • Yakov Lebski 591 posts 2346 karma points
    Mar 08, 2019 @ 08:45
    Yakov Lebski
    0

    Umbraco load all controllers automatically from DLL and appcode, if you have the same controller in appcode and DLL this can cause duplicate name error

  • Henrik Sunesen 84 posts 281 karma points
    Mar 08, 2019 @ 09:39
    Henrik Sunesen
    0

    But is it required to have your controllers in a app_code folder, or is it okay to have them in a folder called "Controllers"?

  • Harry Spyrou 212 posts 604 karma points
    Mar 08, 2019 @ 12:14
    Harry Spyrou
    0

    Aren't your controllers compiled in bin folder?

  • Henrik Sunesen 84 posts 281 karma points
    Mar 08, 2019 @ 16:42
    Henrik Sunesen
    0

    Yes they are in the bin folder

  • Harry Spyrou 212 posts 604 karma points
    Mar 08, 2019 @ 16:49
    Harry Spyrou
    0

    I think -if I understand correctly- that you're confused about the states of the application.

    Your folder named Controllers (or whatever you want to name it) is in the root of the project (usually) when you're working on localhost.

    When you try to run the application, Visual Studio creates a bin folder and all the compiled .cs files (including Models and Controllers) go into the bin folder as DLL files. This is done in the background.

    So, basically if I could guess, unless it's some weird setup, the Controllers on the other project have nothing to do with the fact it's running correctly. The bin folder in there (on the actual server) is the one that makes the application run. Someone correct me here if I'm wrong.

    What i see in your screenshot is a project in an IDE, not a compiled application on the server.

    You shouldn't be trying to make an app_code folder. You probably need to change the language version of your C# in Visual Studio (or whatever IDE you use) and then the problem will go away. Or change the problematic code to something C# 6 understands.

    This is basically what a compiled Umbraco application looks like (with 7.13.2) running on the server:

    enter image description here

    P.S. I even think the sql folder is not used, I should delete it. Here:

    How to change your C# language version - Microsoft Docs

  • Henrik Sunesen 84 posts 281 karma points
    Mar 08, 2019 @ 19:29
    Henrik Sunesen
    0

    I think it's working now, but is it correct that when i publish the site to the server, using VS publish feature, the media folder images are not included?

    And thank you so very much!

    I think my issue was that the earlyer pages i made with umbraco, i just copied the files from local folder to server folder by FTP. But these projects has all had a app_code folder to the controllers. And as far as i understand the unique about that folder is that the files inside it compiles on runtime.

    And when i just copying the controllers folder via. FTP the files are nok correct compiled, thats my theory.

  • Harry Spyrou 212 posts 604 karma points
    Mar 08, 2019 @ 20:05
    Harry Spyrou
    1

    Yeah, it doesn't work that way. Publish somewhere from Visual Studio with configuration set to 'Release'. Then you'll get the compiled app that you can copy to the server(or publish directly to the server, up to you). And yes, Media folder is not included, unless you include it in the csproj (I think).

    I also think best practice is not to include the media folder overall. Just have an empty media folder on the server and Umbraco will populate any images you upload.

Please Sign in or register to post replies

Write your reply to:

Draft