ASP.Net MVC Remote Validation submitting incorrect URL - asp.net-mvc-3

I am following this walkthrough on how to implement Remote Validation. The remote validation method fires when expected, but it is requesting the wrong url. It is requesting
/Validator/IsUID_Available
instead of
http://localhost:23615/Validator/IsUID_Available.
This results in a 404 not found error. What am I missing?

Sorry my bad! I was registering the Remote attribute incorrectly as follows:
[Remote("IsUID_Available", "ValidationController")]
instead of the correct way like this
[Remote("IsUID_Available", "Validation")]

I would venture to say that your url is correct. Its just giving a relative url which should resolve correctly. I'm guessing you have something wrong with your controller or you haven't registered your controller in your routes table correctly.

Related

CanJS can.route.ready() version 2.1- '#!' is changed to '#!&' on clicking the link

I have an application which relies on can.route to capture the #change when the user clicks on a link.
href for the link is having pattern '#!'.
Once the change is capture by the can route utility, i am seeing the hash in the browser changing to #!&.
This is causing an additional entry in browser history stack.
Has anyone faced a similar issue?
Appreciate your help.
Could not provide a fix as there is no code to see how the route is configured.
Looks like you are adding only additional parameters to the route. To confirm, pls execute can.route.attr(); in your developer console of the browser.
If everything is configured properly, you should get something like this for the url http://localhost/example#!currentRoutePage
---> can.route.attr();
Object {route: "currentRoutePage"}
Looks in your case, url is http://localhost/example#!&view=currentRoutePage and so route is null in the object
---> can.route.attr();
Object {view: "currentRoutePage", route: ""}
If this doesn't help much, please share the url you are seeing in the browser and the route configuration for the same.

Custom error handling

I am developing a component in joomla 2.5, my component sends a request to some url and gets the response object. If i pass wrong url, joomla takes me to the default page of Error : 500 - No response code found . I want that if user install my component and mistakenly they put wrong url , it should show some custom error message/page which should more meaningful to non-programming person rather than taking user to default error page. Is there some way to add this type of functionality in Joomla without editing template/error.php file in core.
You should have an error.php file in your template, if you don't add one and make it look the way you want. also remember that when you turn debugging off you won't get the stack trace etc.
However error 500 indicates something different than that the url does not exist ("wrong URL"), which would be a 404. 500 is an internal server error and you need to check your logs to figure out what is causing it.

How to get the primary route, if it doesn't exist and we are being sent to 404 page

So basically I am trying to debug my routes, because they are not working as intended, but when using the profiler, I can see the URI string, which is basically the second part of URL in the browser address bar and CLASS/METHOD which are always of the 404 page that I am being redirected to. So how can I get the primary routes Class, Method and arguments/parameters that were attempted to run before being sent to 404?
E.g.
$route['en/catalog/(.+)/(.+)'] = "ccatalog/index/$1/$2";
something's gone wrong and I get redirected to the 404, but I want to see which class (most likely "ccatalog" here), which method (hopefully "index") and arguments ($1, $2).
Thank you in advance to anyone who could help me with my problem!
I don't see a reason for your route to not work.
Check by directly opening your_path/ccatalog/index/whatever/whatever in the browser.
If it gives you a 404, it means the problem is with your controller, maybe the controller or function naming.
If it is working fine, then you may be able to use a pre_system hook to figure out the parameter values.
You may also consider hacking around with Routing files in the core(making sure you change them back), to figure out what the real issue is.
Actually, this was done really easy:
$this->uri->rsegment(1);

MVC3 using nHibernate

I have an MVC3 project using nHibernate, Rhino and Castle. I finally got all of the components in place. I think. At least it runs and invokes the IWondsorContainer CreateContainer() method....after that method, the Application_Start does not fire and I get the message:
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: /Views/Proposal/Index.cshtml
Any ideas? I don't know what to make of this. Thanks
You seem to be requesting a view directly: /Views/Proposal/Index.cshtml. In ASP.NET MVC you do not request a view. You request a controller action. So in your browser the url should be /Proposal/Index or simply / depending on how your routes are configured.
I suspect that you had the focus on this Index.cshtml when you hit F5 in Visual Studio which has this ugly habit of following the url. You could define a start url in the properties of your web project to avoid this behavior.

Open Ajax Issue

When I run my ajax file, a problem caused by XMLHttpRequestObject.open("GET", dataSource,true) occurs. It is said that " Access to restricted URI denied" code: "1012" ". Does anyone know the solution? Thanks in advance!
You are probably trying to access a file on another domain. This is forbidden in AJAX for obvious security reasons.
If the data source is one you control, try using JSONP in order to circumvent this restriction. Otherwise, you're out of luck for the most part, unless you want use server-side code to route the request through your own server.

Resources