11

I am using Visual Studio Express 2012 RC.

  • If a create a blank "hello world MVC 4.5 project"
  • I Downgrade it to 4.0 so it is compatible with my host (Arvixe)
  • I publish it to the host.

And then i get this error message, i can find any information on it online.

Server Error in '/' Application.

Directory does not exist.
Parameter name: directoryVirtualPath

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ArgumentException: Directory does not exist.
Parameter name: directoryVirtualPath

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[ArgumentException: Directory does not exist.
Parameter name: directoryVirtualPath]
   System.Web.Optimization.Bundle.IncludeDirectory(String directoryVirtualPath, String searchPattern, Boolean searchSubdirectories) +357
   System.Web.Optimization.Bundle.Include(String[] virtualPaths) +287
   IconBench.BundleConfig.RegisterBundles(BundleCollection bundles) +75
   IconBench.MvcApplication.Application_Start() +128

[HttpException (0x80004005): Directory does not exist.
Parameter name: directoryVirtualPath]
   System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9160125
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +131
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +194
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +339
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +253

[HttpException (0x80004005): Directory does not exist.
Parameter name: directoryVirtualPath]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9079228
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +256

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.237

What does it mean ?

Code as requested^^

public class HomeController : Controller
{
    public ActionResult Index()
    {
        return Content("Hello world");
    }
}

thats the only code i added.

application_start code

public class MvcApplication : System.Web.HttpApplication
{
    protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();

        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
        BundleConfig.RegisterBundles(BundleTable.Bundles);
    }
}

RouteConfig

public class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
    }
}

FilterConfig

public class FilterConfig
{
    public static void RegisterGlobalFilters(GlobalFilterCollection filters)
    {
        filters.Add(new HandleErrorAttribute());
    }
}

BundleConfig

 public class BundleConfig
{
    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-1.*"));

        bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
                    "~/Scripts/jquery-ui*"));

        bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                    "~/Scripts/jquery.unobtrusive*",
                    "~/Scripts/jquery.validate*"));

        bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                    "~/Scripts/modernizr-*"));

        bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css"));

        bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
                    "~/Content/themes/base/jquery.ui.core.css",
                    "~/Content/themes/base/jquery.ui.resizable.css",
                    "~/Content/themes/base/jquery.ui.selectable.css",
                    "~/Content/themes/base/jquery.ui.accordion.css",
                    "~/Content/themes/base/jquery.ui.autocomplete.css",
                    "~/Content/themes/base/jquery.ui.button.css",
                    "~/Content/themes/base/jquery.ui.dialog.css",
                    "~/Content/themes/base/jquery.ui.slider.css",
                    "~/Content/themes/base/jquery.ui.tabs.css",
                    "~/Content/themes/base/jquery.ui.datepicker.css",
                    "~/Content/themes/base/jquery.ui.progressbar.css",
                    "~/Content/themes/base/jquery.ui.theme.css"));
    }
}
4
  • Sure will do, but it's just a test. Commented Jul 4, 2012 at 17:13
  • 1
    can you post the code inside application_start ? Commented Jul 4, 2012 at 17:14
  • @BjarkeCK thanks.are you sure all of files included in RegisterBundles exist in you'r application's directory? Commented Jul 4, 2012 at 17:21
  • @BehnamEsmaili Interesting, i maybe excluded the Content folder when i published :), will try to delete all the bundles and publish again! Commented Jul 4, 2012 at 17:26

6 Answers 6

17

it seems that this error originates from "not including desired files in your application's directory" or uploading your code in a directory that is not configured as virtual directory , or even in incorrect directory.

Sign up to request clarification or add additional context in comments.

4 Comments

I think you are very right :) Will test it, and be back in a min
Well i think that resolved the issue, but now it's a new one: http:**temp.iconbench.com/
Allright, now i'm at least one step closer. Thank you alot for your help, learned alot.
6

This post is similar to Directory does not exist. Parameter name: directoryVirtualPath

The answer helped me debug. Apparently, there are missing folders on the target server. My application worked fine locally, but when I published, several script sub-directories did not get published. When I manually FTP'd them up, the app worked fine!

1 Comment

This was my issue too. Visual Studio doesn't seem to Publish empty directories by default, even though the application uses them and they are Included in the Project.
3

To expand on the information here.

I often bundle all file in a folder like so: "~/Content/js/angular/modules/*.js", And this works great as long as the folder exists.

The issue is, if that folder is empty when you publish it will not be published and will result in the above exception. So now i either put an empty.txt or something of the sort of add the folder manually if i want them to remain empty for now.

Comments

0

check if you have dll in bin folder and also the dll exist in the GAC

remove dll from GAC

Comments

0

In my case it was "Content" folder which I forgot to upload to the server

Comments

-4

Create directory "/Content/themes/base"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.