Early in my project they were working fine. Now the client side validation isn't working, it wants to post back before telling me that a required field is required.
It's not working on my local environment nor on the server. Is there possibly some scripts that aren't getting copied? Did I delete a required reference? I'm using a project type, not web site type with .Net 4.
I tried starting a new project and copying over my form, and it works as expected.
Turned out to be a problem with routing.
Viewed the source of the page, clicked on the validation script, and it wasn't going to the right place :/
routes.Add(new Route(
"{resource}.axd/{*pathInfo}", new StopRoutingHandler())
);
Related
I am working on a custom action for our company's shopping cart website. It is a software that is installed and setup, and we are able to add to it by creating custom actions. I created an ASP.NET (web forms) page that uses SignalR to add to it, but whenever it tries to grab an instance of the hub within javascript, it is always undefined.
In Chrome, I can see signalr/hubs, and there are no 404 not found errors on the page either. It works perfectly fine when running it in debug from VS 2012, but not from within the web site on the server.
I am certain I have deployed all the necessary components, and have tried many approaches to changing the way it finds the hub, but nothing seems to work.
I can provide code samples if needed.
I found the issue. It was related to the name of the hub being misspelled in javascript. Once that got fixed, then the function name needed to be changed in javascript so the first character is lowercase. It is working as intended now.
I have a basic question
I started to work with asp for a client, and I built some pages with buttons and grids and so on, and now I want to give him the result of the work.
How do I do it?
In a "normal" application - I give him the exe file and all the dlls, but in asp I didn't found any of this, so what I give to him?
thanks
Continue from comment ...
Right click on web project, and click on Publish...
Then create a new profile, and select File System at Publish method.
So, I've copied a few methods from one controller to another, moved the respective views into the correct view folder and tried to debug my project..
After trying to navigate to one of the newly copied methods and views I get hit with this lovely error.
Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /subscriber/addphonenumber
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.57.0
Now, I've double and triple checked that the views are in the right folder, even deleted them, went to the controller actions, right click -> add view and copied the view code over and still no joy.
The controller actions are there, the views are there, what gives?
I've tried cleaning the project, the solution, closing VS and restarting and still... nothing.
Also, when debugging, my breakpoints are never getting hit on the newly copied methods... Not sure what is going on there.
Note: I have NOT made any changes whatsoever to any of the routing configuration, I simply copied the ChangePassword, AddPhoneNumber and VerifyPhoneNumber actions/views from the Manage Controller and Views folder to my Subscriber Controller. These methods and views worked fine before I moved them.
Questions:
Why is Visual Studio not hitting my breakpoints
Why are these views and controller actions not being recognized?
EDIT
I resolved this issue, check below to see my answer.
The solution in my case ended up being this.
I had an area in my project with the same name as a controller in the root controllers folder, that was causing a routing issue and in turn the 404 error. The routing issue prevented my actions from being found, hence the breakpoints not being hit. After removing or renaming the area, everything seems to be working fine.
Project Structure
areas/subscriber - empty
controllers/subscriber
views/subscriber/index
views/subscriber/addphonenumber
I have an MVC4 app, but I'm primarily using it for the WebAPI parts. I want to have a "plain old HTML" file sent back to the user (which will then use KnockoutJS or KendoUI to pull JSON from the webapi controllers).
I know I can do this:
routes.IgnoreRoute("{page}.html");
And then if I browse to "localhost/index.html" it does successfully just return my .html page.
However, I really want to map the "root" default path "localhost/" to return my index.html.
I tried this:
routes.MapPageRoute("root", "", "~/index.html");
but that throws the error:
There is no build provider registered for the extension '.html'. You can register one in the <compilation><buildProviders> section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.
Anyone have any ideas on how I can make this work? I could just hit a default controller that returns a plain html page, but it seems like overkill to go through the entire ASP.NET stack once for the HTML page, which then just calls a WebAPI URL to go back through the ASP.NET stack to get some JSON data for the page's model.
I basically just want to "skip" all the MVC plumbing and have IIS send me back the html page, as if it wasn't an ASP.NET app, or at least do as little processing as possible.
Add the following to your routing config:
routes.IgnoreRoute("");
I'm not new to ASP.NET MVC but I have a really strange issue that I haven't been able to solve. I've checked most other related queries on SO and further afield but I haven't yet found a solution. I have a really simple ASP.NET MVC 3 application running under Cassini which was working fine until I added log4net logging. I've since removed all the references to log4net to try and get it back but I always get the error:
Server Error in '/' Application.
The resource cannot be found.
HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed blah...
This is the result, no matter which url is requested.
The application still has the original HomeController, Index.cshtml etc and the default route from the standard 'out-of-the-box' Visual Studio 2010 template.
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
I've checked and double-checked that there is no file missing (e.g. a css or js file) thats required and another issue which prevents me from moving forward on this issue is that no breakpoints are hit when trying to debug it. In fact, if I put a breakpoint on the first line in the Application_Start method, and start debugging, the breakpoint is not hit at all and a second breakpoint appears (see the image below)!
This happens even if I do a clean and rebuild.
I've tried using Phil Haacks Route Debugger but still get the same error and the fact that the Application_Start breakpoint is not being hit makes me suspect my web.config. I've checked it several times and in fact replaced it with a web.config from my hosted site where the application is running ok, but still get the same result on my development setup.
I've checked there is no StartUp page in the properties.
I want to add some more functionality and be able to debug it before deploying to my hosted site but this is stopping me.
Has anyone come across breakpoints being added when you start debugging? Considering the symptoms, where would you start looking for the root of the problem?
Just solved it, so for those who might trip over this one, I've noted the reason why below. However, what might be of more value was my approach to find the issue in the face of no debugging or tracing available. As it is still a small site I decided to create another standard 'out-of-the-box' MVC 3 application and manually compare files. There appeared to be no difference between files but while going through this exercise I noticed that in the problem application, the Global.asax files were sitting in the Views folder! I must have inadvertantly moved them - it wasn't immediately obvious because the Views folder was always expanded and glancing at it, would appear that the Global.asax files were in the right place because they are normally immediately below the Views folder (just not indented as they are when inside the Views folder).
Anyway, problem caused by me but did cause some weird behaviour!