Deployment of Asp.Net MVC app on Win2k3 issue - asp.net-mvc

I’ve created an ASP.net mvc application on my windows XP machine. Now, I’m at the stage where I want to deploy my application. I’ve done some googling on how to install/configured MVC apps under IIS 5.1 and 6.0 but I’m still having issues although I’ve done everything, so I believe, by the book.
On my XP box, I’ve created a Virtual Directory and added the Application Mapping “.*” and unchecked the “Check that file exists”.
When I navigate to localhost/vince/ my page displays great! Once logged, I’m being redirected to:
localhost/vince/Transaction/Index
The view (Transaction/Index.aspx) simply displays business information…
The user, has the liberty to edit his account by clicking the MyAccount link which brings him to:
localhost/vince/Account/Index
I have a cancel button at the bottom of that view which basically brings you back to:
localhost/vince/Transaction/Index
The view source of that cancel button is this:
<input onclick="location.href='/Transaction/Index'"
type="button" value=" Cancel " />
The problem is when the user clicks the cancel button he is being sent to localhost/Transaction/Index
And I get a 404 page not found…Notice how the name of my virtual directory “vince” was removed.
To further my testing…I’ve decided to deploy my MVC app on Win2k3 with IIS 6.0. Created the exact same thing, Virtual Directory and added the Application Mapping, only to realize that it was doing the same thing. Now instead of creating a Virtual Directory, I created a WebSite. Oddly enough, it now works without having to change anything…does anyone know why it now works within a new WebSite as opposed to a new Virtual Directory.
Thanks

Your cancel button is sending the browser to /Transaction/Index. The important thing to note is the leading slash on that URL. This is sending you to the root of the site (with no virtual directory included). That's why it works on IIS 6 when you create a website - there is no virtual directory being used there.
The fix for this is to use the Routing infrastructure to generate the link for the cancel button - it sounds like you are already doing this for the other links in your application.

It doesn't sound like a server setting, os version, or iis version issue... What is the exact url that your cancel button is requesting?

Change your HTML to:
<input onclick="location.href='<%= Url.Action("Index", "Transaction") %>'"
type="button" value=" Cancel " />

Related

Button not working in asp.net mvc application (environment specific)

I have a asp.net mvc application deployed in production. User can save a form in draft state and then can submit the form later. This functionality is working perfectly but for two of our users in Malaysia, when they click on Submit button, nothing is happening. It seems that the button is not working (page is not posted back).
I am unable to understand what could be the possible cause. If there is a firewall issue, then site would not have been opened at all.
Can I use fiddler to check or if there are some other options?

ASP MVC 2 with asp.net development server won't load default controller & action for an empty route

This used to work fine, but recently it refuse to load the default page for an empty route, instead it lists directory contents.
for example
http://localhost:1234/ should take me to the same page as http://localhost:1234/Home/Index assuming global.asax hasn't been modified, however recently it just takes me to "Directory List -- /" and lists out the content of the project folder.
This is using the ASP.NET Development Server. The sites work fine when deployed into IIS on a server.
Does anybody have any ideas, this is really annoying!
I would check the project settings like suggested on this other question:
Launching my debug MVC3 application opens a specific .cshtml file in the browser
Through trial and error I've determined that this is caused by the IBM RTC plug-in, when disabled it works normally.
I find this very surprising, but I've double checked and it is definitely that!

Running ASP.NET MVC application in a subdirectory, getting 404 errors

I have an application that uses ASP.NET MVC. I have it deployed to a Crystal Tech server (hence, no direct access to IIS control panel).
Initialy this was running in the root directory and everything was OK. The client then decided that it needed to run in a subdirectory. I moved the app there and the home index page comes up, but every other page tries to access the the controller/action/page/view in the original root directory. I don't understand this, since the references were all contextual (i. e. using ../controller/action as opposed to mysite.com/controller/action).
Am I doing something wrong here? What are my options?
Thanks,
James
I would use the UrlHelper to generate the links. This would ensure that they are relative to the application path.
Link Text
and
<img src="<%= Url.Content( "~/images/myimg.jpg" ) %>" alt="My Image" />

asp.net mvc - site works fine locally but not after deployment

i have an asp.net mvc website. http:/mywebsite.com (just for this example)
I have been testing this asp.net mvc website locally on my machine and everything works fine on my local machine during testing. When i deploy to my web server
when i bring up http://mywebsite.com it goes to HomeController and load the view Views/Home/Index.aspx (which is perfect). So the main default page is fine.
The issue is, if i click any other other links (again that all seem to work fine locally) i get the following error:
The page cannot be found
The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.
Please try the following:
* Make sure that the Web site address displayed in the address bar of your browser is spelled and formatted correctly.
* If you reached this page by clicking a link, contact the Web site administrator to alert them that the link is incorrectly formatted.
* Click the Back button to try another link.
HTTP Error 404 - File or directory not found.
Internet Information Services (IIS)
some examples would be:
http:/mywebsite.com\Photos
http:/mywebsite.com\Links
there definitely are controllers and views setup for this (or it wouldn't work locally).
does anyone have any idea how this might work fine locally but somehow on the webserver it doesn't
Are you running the site on II7 in integrated mode? If not, you need to add a wildcard handler so that all URLs get mapped to your application. See Phil Haack's blog post on running ASP.NET MVC ON IIS 6.
Something else to watch out for. I had a static website - deployed on IIS 7.5. Added some MVC Controllers to handle some simple server side apps and then re-deployed it. I didn't copy the web.config file, because I wrongly assumed that everything that was needed was in the one that was automatically created by the server.
You must copy the web.config up as well.

ASP.NET web site on IIS7 on Vista

I have dev an MVC app and deployed it to my local IIS as I am using dev server to dev.
This is on Vista Ultimate.
When i browse the site all the images are not showing and also the
login page is displayed.
what would be causing the images not to show and also why
the login page showed when I have not set up security
in web.config?
I tried to see if the ASPNET account had permissions
but there is user of that name and there is no
Add option in properies either.
Malcolm
This could be a deployment issue, rather than a permissions issue. Did you try to browse directly to an image via your browser?
So if you have an image located in your project as
\images\login.png
open in your browser to:
http://hostname/images/login.png
If this works, then you have got a referencing problem in your html. From memory, most images in asp.net mvc are located with:
src="../../images/login.png"
This could break down if your pathing is different to the current location.
I usually prefer this:
src="/images/login.png"
or even better:
src="<%= ResolveUrl("~/images/login.png")%>"
I had a problem with images displaying in an MVC app until I coded the image tags like this:
<img src="<%= Uri.Content("./content/images/image.png") %>" alt="text" />

Resources