Currently the Url.action hard codes the action and controller. I want to replace the action with the actionName passed into the function and the controller with the controllerName passed into the function.
When I replace "getURL" with actionName and "RequestProcess" with controllerName I receive the following error:
Server Error in '/Apps/Referrals' Application.Compilation ErrorDescription: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS0103: The name 'actionName' does not exist in the current contextSource Error:Line 179: async: false,Line 180: type: 'GET',Line 181: url: '@Url.Action(actionName,controllerName)',Line 182: success: function (data) {Line 183: //callbackSource File: d:\websites\i21\Apps\Referrals\Views\Home\Index.cshtml Line: 181
As I noted in my post, I have tried that already but it generates an error when I try and generate the page. Here is the screen shot showing the VS red line under the variables indicating it doesn't like something. UrlActionError.fw.png
Lokesh B R
Hi,
try this
<script type='text/javascript'> function getURL(controllerName, actionName, routeVals) { var result = 0; var Url = actionName + "/" + controllerName; $.ajax({ url: '@Url.Action(Url.ToString())', data: { routeVals: routeVals }, async: false, type: 'GET', success: function (data) { result = data; } }); }</script>
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: /Home/0
Open in new window