Upgrade 4.11.10 to Umbraco v6.2.5 - Unable to set correct <form action=""> for rewritten URL - webforms

I have just performed an upgrade from 4 to 6 (still using WebForms) and got most things working again - but I'm unable to set the HTML form action correctly on a page with a usercontrol on a page which has a rewritten URL. The nice URL is like /developer-job-in-london-J12345 and the rewritten URL is /jobs/details.aspx?JobRef=J12345.
On v4 I just set the Request.Page.Form.Action to the Page.Request.RawUrl in the UserControl code, running the same code in v6 seems to work fine - but looking in the HTML output, it's still using the rewritten URL as the action (/jobs/details.aspx). Which means you're sent to a different URL on postback and a new entry is added in your history.
I can check Page.Form.Action and it looks correct from the control Page_Load and the master pages (actually tried all the events I could think of), but as I say, the final HTML is always incorrect.
Has something changed in v6 relating to this? Is there anything I can do to avoid having to fix this in JavaScript!? :(
New assembly version is: 1.0.5529.18434 if that matters.
Thanks!
Edit
<add name="JobRewrite" virtualUrl="(.*)-job-J(.+)$" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/Jobs/Details.aspx?JobRef=J$2" ignoreCase="true" />
Edit 2
Stranger and stranger: This was working fine on my CI server - the action is set correctly, but I have a mobile site which is just a WebForms project, with Umbraco installed so I can use the membership provider. That site appeared to have the opposite problem - there's a search form there which has a blank action on my CI server, but works fine on my dev machine.
However, I've now fixed that with help from here: https://stackoverflow.com/a/15353347/48348 - and it turns out to be a problem with changing my project to the latest version of ASP.NET - and the handling of form actions for default documents. Not sure if that can actually be related to this as it's Umbraco that should be handling everything here? Hmm...
As a slight aside: I'd love to use LESS umbraco on that site, but am struggling with that, too - question about that here: https://our.umbraco.org/forum/developers/api-questions/63161-Use-Umbraco-membership-(and-profile)-provider-in-non-Umbraco-ASPNET-web-forms-site

Related

Should Google Tag Manager code be inserted in an ASP.NET Site.Master?

We are implementing Google Tag Manager in our web site. The site is an ASP.NET Web Forms site. It seems to me that the optimal way to implement this is to insert the Google code in Site.Master.aspx - is this correct, or is there a better way?
Thanks!
For our webforms site, we put our tag manager code in the master page, both in order to ensure that the code is in the right place (at the very beginning of the body tag) and also to easily get it loaded onto every page. Unless you have some unusual circumstance I think that seems most logical to me.

Blank page on Azure

I have an application running in Azure (trial account). So far so good, everything has been nice, except for a long deploy times (10-15 minutes).
I've done a deploy recently and got a lot of weird bugs I cannot trace. For example, if I log in and thus a cookie is created (I use FormsAuthentication) all I get from the application is a blank page, as in, absolutely nothing is sent to the browser. The application works fine in the ASP.NET Web Dev Server, IIS Express, even the Azure Emulator!
What could be the issue? Searching the web hasn't been much help, with only a couple of unrelated issues.
I tried logging into the site (if I correctly understood from one if the comments, the url is versulo.com) and I didn't get any blank page with 404 status code.
However, there is another problem I spotted. Your site seems to be implementing caching inappropriately. The main page, the one from which you trigger the login and which is dynamic in nature contains an Expires header set at 5 minutes after the pages first load. That means that each call or redirect to that page within 5 minutes since it was first loaded, will be served from the browser's cache.
Because of that, after I login into your application I am redirected back to the home page which looks like I am not logged in. If I force a F5 refresh on the browser, then the page will indeed show me as logged in.
If instead of a refresh I try to login again (which is what I did in my first trials, since it looked like the login didn't work in the first time), I am getting an error page with the following message:
Sorry, there has been an error on the server.
500
The page looks like an application error page and even if it displays the 500 number, it is actually served with an HTTP 200.
So, while I am not 100% sure if this is also the cause of the problem described by you, you should remove the Expires headers from the dynamic pages your application is serving.
This can be because you're combining Forms Authentication with multiple instances. Are you using multiple instances? If that's the case, could you:
Try to change it to 1 instance. Does this fix the issue?
Try to make the following change to the web.config (configure machineKey): http://msdn.microsoft.com/en-us/library/ff649308.aspx
some partial views are not rendered at all;
Do you mean some pages are working fine, but others are not? It would be better if you can point out a pattern on what’s working and what’s not? For now, please make sure all referenced assemblies (except for default .NET assemblies and Windows Azure runtime) have Copy Local set to true. For example, MVC assemblies are considered as extensions to .NET, so please set Copy Local to true. In addition, you can also try to use Fiddler to monitor the requests to see what’s returned from the server.
Best Regards,
Ming Xu.
Could you provide a link to the application, or perhaps some source code?
When you say 'blank page', what is actually returned, a 404 / 500?
Have you inspected the IIS logs, or added some trace information to your code?
Have you tried accessing the service using it's ip address rather than domain name?

Unable to see images, css files or use javascript in MVC 3 website deployed on IIS 7 in classic mode

I have an ASP.NET MVC 3 website that works perfectly in IIS7 integrated mode. However, I need to deploy this in classic mode.
In order to do so, we manually inserted the handler mappings in IIS to handle urls for .mvc extensions as suggested in the link in the global.asax file.
But in classic mode, none of the static files (css, images, javascript) are getting loaded. Is there some other setting that I need to do to get these working.
When I tried to see these in fiddler, I can see an HTTP error 500 for all of them. I have already tried the following approaches:
Added the following line of code in the web.config httpHandlers section
add verb="" path=".png" type="System.Web.StaticFileHandler"
Checked the 'Static Content' in Common HTTP features on IIS.
I am not sure what to try next.
The usual workaround is to configure "Wildcard Script Map", please read more here.
The issue was related to improper relative paths, which didn't work out when we deployed. Having the proper relative path showed the images and other files perfectly.

FTP deployed Microsoft MVC3 website. POST protocol ISN'T working. GET protocol IS working

I am developing a website using Microsoft MVC3, and have built it upon the default MVC3 Application template. It accesses an external database and works on localhost.
I have deployed it to a shared server I rent from storminternet via the publish tool using ftp method (storminternet do not yet support web deploy), and it runs well. It accesses the database okay and get requests work fine.
However, any form that submits via POST protocol returns page not found error 404 (this is on actions where I have asserted [HttpPost]).
Storm internet assure me that POST and GET are allowed by default, and since the helpdesk are not developers, I'm unsure who to turn to. I don't have an excellent understanding of web.config, although I can read and understand xml and see what's going on by reading through and googling. I have tried adding the protocols to the root web.config, and I think I might be barking up the wrong tree.
Has anyone else had this problem, or might anyone know how to help me?
To replicate my error, my site is here... 213.229.125.117/$sitepreview/ase-limited.com/Dev (sorry it isn't blue. The dollar gets parsed to % something)
and the quickest route to a POST request is to click 'Add Building' at the top of the left-hand side and then click 'Save' at the top of the dialogue box.
Any help will be gratefully received. I've been stuck on this for days without luck.
Best Regards
Nick
STOP-PRESS-STOP-PRESS-STOP-PRESS-STOP-PRESS-STOP-PRESS-STOP-PRESS-STOP-PRESS-
It turned out to be a known issue with sitepreview. Switching to the proper domain sorted everything.
I have noticed that you have some 404 javascript errors when performing your AJAX requests. For example you have a request to:
http://213.229.125.117/$sitepreview/ase-limited.com/BuildingManager/Employees/2
instead of:
http://213.229.125.117/$sitepreview/ase-limited.com/Dev/BuildingManager/Employees/2
Notice how /Dev is missing. That's because in your javascripts you have hardcoded your urls instead of using url helpers to generate them. For example you wrote something like this:
$.ajax({
url: '/BuildingManager/Employees/2',
....
});
which works fine on localhost because you don't have a virtual directory name but doesn't work when you deploy on your server because now the correct path is:
$.ajax({
url: '/Dev/BuildingManager/Employees/2',
....
});
For this reason you should absolutely never hardcode urls like that.
And when I try to POST the form in tries to post to http://213.229.125.117/Dev/BuildingManager/SaveBuilding which seems a very weird url as it is missing the whole beginning. Once again: never hardcode urls. Always use url helpers.

IIS7 MVC deploy - 404 not found on some actions

Once deployed parts of my web-application stop working. Index-es on each controller do work, and one form posting via Ajax, Login works too. Other then that yields 404. I understand that nothing particular should be done in integrated mode.
I don't know how to proceed with troubleshooting.
Some info:
App is using default app pool set to integrated mode.
WebApp is done in net framework 3.5.
I use default routing model.
OS is Windows Server 2008.
IIS 7
Any help is appreciated. Thx.
EDIT:
I determined that only actions that accept ID parameter don't work. On the contrary, when I add dummy id method in Home controller of default MVC app it works.
EDIT 2:
I found the problem. Links on few pages of the site didn't use ActionLink helper. It was harder to see because of the Ajax invoking. So, never hardcode links to the actions on the site, even temporary.
Please go through this link for details on deploying MVC application with IIS 7 integrated mode.
http://www.asp.net/mvc/tutorials/older-versions/deployment/using-asp-net-mvc-with-different-versions-of-iis-cs

Resources