0

I've got a simple ASP.NET MVC application for CSV file validation. The user enters some characteristics about the file (text box and some checkboxes), then browses to the file they want to upload and hits submit. The entire application works fine on my local machine and also on an internal web server, but does not work when placed in the external hosting environment. Below are the details.

Originally the file contents on my machine were copied out to the server. This means that bundling of the CSS and JS was not enabled. The application page would render just fine and the submit would also work. However, after submitting the file, the application root changes.

I've been checking the application root with the following code places inside the view.

var applicationpath = '@Url.Content("~/")';

The path is correctly output as something like the following when it's rendered for the first time.

var applicationpath = '/folder1/folder2/folder3/appfolder/';

After submitting the file, it changes to.

var applicationpath = '/folder1/folder2/folder3/';

I've checked with the hosting provider and they've got the application set up on "appfolder" and "folder3" is just a directory in IIS and not set up as an application.

The form in the MVC view is set up to post in the following way.

@using (Html.BeginForm("Upload", "Home", FormMethod.Post, new { enctype = "multipart/form-data", id = "wizard" }))

Since the path changes, this obviously messes up any @Url.Action,@Html.ActionLink, and other Razor methods that are supposed to automatically map to the root. The odd thing is that the CSS and JS files continue to be mapped in the rendered output.

After all of that, I decided to try to Publish the application through Visual Studio to a local file folder and then copy the results out to the hosting provider. This enabled bundling for the CSS and JS files. Now when I go to the root of the application, none of the CSS or JS is pulled down. I've tried grabbing the path to the bundled JS or CSS files and putting that in the browser, but I get a 404 error. The rendered output looks like this:

<link href="/folder1/folder2/folder3/appfolder/Content/css?v=J7SZFaeCsOxTbb847HlSpnWlcb1lMDolldSj5wq-hdc1" rel="stylesheet"/>

Needless to say, I'm at a loss. I've asked the hosting provider to tell me what IIS features they have installed and they have. See below.

IIS Features 1

IIS Features 2

amrinea
  • 553
  • 4
  • 12
  • Few questions: 1) Are folders 1,2,3 folders that you control or just your host provider? 2) What is your controller doing on the post? – TSmith Oct 25 '13 at 14:40
  • To be honest, I haven't been uploading the files, but it's been done by someone in the graphics design area of the company. That being said, we might be able to control some of the folder structure, but not likely all of it. I know that we don't have access to IIS to modify those types of settings. – amrinea Oct 25 '13 at 15:12
  • The controller accepts the model and the HttpPostedFileBase. From there it is opening the file InputStream, loads it, and does a bunch of checks on it. At the end, which is probably what you're most interested in, it sets a property in the ViewBag and then does `return View("Index", du);` which takes them to the same view they started on. The address bar changes to "/folder1/folder2/folder3/appfolder/Home/Upload". – amrinea Oct 25 '13 at 15:21
  • Any chance you can get an image of the tree view of the site under IIS? If appfolder is the application's VD root, it's weird those other folders are being listed in the relative path for the css bundle. – TSmith Oct 25 '13 at 15:43
  • I have an image, but I don't think I can share it given what it shows. Anyhow, it appears that the level above it (folder3), is just a folder and not marked as an application. It appears that only the folder containing the application is actually set up as an application in the structure. I'm going to check with them to make sure of that since I can only see 1 level up. – amrinea Oct 29 '13 at 13:09
  • I got the entire tree from the hosting provider and everything is just a simple folder all the way up to the top. The only folder that is an application is my app folder. – amrinea Oct 29 '13 at 15:38

1 Answers1

0

The 3rd party was able to give me RDP access to the server. I turns out that they were using URL Rewrite in IIS and some of the rules were interfering with the MVC application. After they disabled the rules for the application folder, everything worked as it should.

amrinea
  • 553
  • 4
  • 12