Exploring the wonders of AJAX in ASP.NET MVC 1.0 on the seamless IIS 6 platform

While working with AJAX and jQuery in ASP.NET MVC on IIS 6.0, I encountered an issue where invoking an action via jQuery resulted in a 403.1 error. Is there something specific that needs to be added to the web.config file to address this problem?

Client-Side Code

<script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"></script>
<script src="../../Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>

<script src="../../Scripts/jquery-1.3.2.js" type="text/javascript"></script>

<script type="text/javascript">
    function deleteRecord(recordId) {
        // Perform delete
        $.ajax(
        {
            type: "DELETE",
            url: "/Financial.mvc/DeleteSibling/" + recordId,
            data: "{}",
            success: function(result) {
                window.location.reload();
            },
            error: function(req, status, error) {
                alert("Unable to delete record.");
            }
        });
    }


</script>

<a onclick="deleteRecord(<%= sibling.Id %>)" href="JavaScript:void(0)">Delete</a>

Server-Side Code

[AcceptVerbs(HttpVerbs.Delete)]
public virtual ActionResult DeleteSibling(int id)
{
    var sibling = this.siblingRepository.Retrieve(id);
    if (sibling != null)
    {
        this.siblingRepository.Delete(sibling);
        this.siblingRepository.SubmitChanges();
    }

    return RedirectToAction(this.Actions.Siblings);
}

Error Message

CGI, ISAPI, or other executable program execution is not allowed from the current directory resulting in an HTTP Error 403.1 - Forbidden: Execute access is denied.


Update

It was pointed out by Darin that adding the DELETE verb to the .mvc extension helps, however I am now facing the following issue:

[HttpException (0x80004005): Path 'DELETE' is forbidden.] System.Web.HttpMethodNotAllowedHandler.ProcessRequest(HttpContext context) +80 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute() +179 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Status: 405 - Method not allowed

Answer №1

Once you've linked the .mvc extension to aspnet_isapi.dll in IIS, make sure to activate the DELETE verb:

image link http://support.citrix.com/article/html/images/CTX104183-1.gif

Answer №2

Here's a code snippet to modify settings programmatically:

class IISDirectoryEntry
    {
        public void UpdateProperty(string path, string property, string value)
        {
            try
           {
                DirectoryEntry entry = new DirectoryEntry(path);
                PropertyValueCollection propValues = entry.Properties[property];
                object[] values = ((object[])propValues.Value);
                int searchIndex = value.IndexOf(',');

                int index = -1;
                foreach (var val in values)
                {
                    if (val.ToString().ToLower().StartsWith(value.ToLower().Substring(0, searchIndex + 1)))
                    {
                        index = Array.IndexOf(values, val);
                        break;
                    }
                }

                if (index != -1)
                {
                    values[index] = value;
                }
                else
                {
                    List<object> valueList = new List<object>(values);
                    valueList.Add(value);
                    values = valueList.ToArray();
                }

                entry.Properties[property].Value = values;
                entry.CommitChanges();
                Console.WriteLine("Settings updated successfully.");
            }
            catch (Exception e)
            {
                if ("HRESULT 0x80005006" == e.Message)
                    Console.WriteLine(" Property {0} not found at {1}", property, path);
                else
                    Console.WriteLine("Failed to update property: \n{0}", e.Message);
            }
        }

        public void ModifyIIS6Settings()
        {
            if (IISVersion < 7.0)
            {
                IISDirectoryEntry iisEntry = new IISDirectoryEntry();
                string systemDir = Environment.GetEnvironmentVariable("windir");
                iisEntry.UpdateProperty("IIS://localhost/W3SVC/" + SiteID + "/ROOT", "ScriptMaps",
                @".aspx," + Path.Combine(systemDir, @"\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll") + ",1,GET,HEAD,POST,DEBUG,DELETE");
            }
        }
    }

This can be helpful for configuring settings during installation.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Retrieve the values by accessing an element upon clicking the "Submit" button

Here is an interesting example that I found on this website I am currently working on a simple webpage to display both the current forecast and extended forecast. This is my Index.html: <!DOCTYPE html> <!-- To change this license header, choose ...

The error message "E/Web Console(8272): Uncaught ReferenceError: functionName is not defined:1" popped up when trying to load web views within a

I'm working on incorporating webviews into a view pager. public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = null; v = inflater.inflate(R.layout.webview_l ...

Iterating through a jQuery function to increment value

I have encountered an issue while trying to calculate the total value from an array of form fields. The problem lies in how the final value is being calculated on Keyup; it seems that only the last inputted value is being added instead of considering all t ...

Load Bootstrap 4 Modal with Ajax

I recently upgraded from Bootstrap 3 to Bootstrap 4.1 Within my applications, I utilize ajax loaded modals. In the layout, I have: <div class="modal fade" id="myModalToFillInfo" tabindex="-1" role="dialog" aria-labelledby="myModalToFillInfoLabel" ari ...

Is there a way to determine which radio button has been chosen using jQuery?

I'm trying to retrieve the value of the selected radio button using jQuery. Can anyone help with this? Currently, I am able to target all radio buttons like so: $("form :radio") But how can I determine which one is actually selected? ...

In order to enable automatic playback of background images

Having created a slider with hover functionality on icons to change background images, I now seek to add an autoplay feature to the slider. The slider was implemented in a WordPress project using Elementor and involved custom Slider creation through JavaSc ...

What is the best way to use jQuery to update the color of an SVG shape?

Hello everyone! I'm excited to be a part of this community and looking forward to contributing in the future. But first, I could really use some assistance with what seems like a simple task! My focus has always been on web design, particularly HTML ...

"Server request with ajax did not yield a response in JSON format

http://jsfiddle.net/0cp2v9od/ Can anyone help me figure out what's wrong with my code? I'm unable to see my data in console.log, even though the network tab in Chrome shows that my data has been successfully retrieved. Here is my code snippet: ...

Enhance your mouse movement for optimal efficiency

I am looking to implement a feature on a webpage where a menu is displayed whenever the cursor is near the edge of a <div>. One way to achieve this is by using the .mousemove function to track the cursor position and show/hide the menu based on proxi ...

Is it possible to use Ajax to prompt a pop-up window for basic authentication when logging in?

While attempting to access the reed.co.uk REST web API in order to retrieve all related jobs, I am encountering an issue. Despite passing my username and password, a popup window keeps appearing when I call the URL. The alert message displayed reads: i ...

Completing a form and saving data to a document

I have a form that successfully writes to a text file using PHP. However, after submitting the form, the page reloads and shows a blank page. Currently, there is a message that appears using jQuery after the form is submitted. My goal is to prevent the pa ...

Using Web API Controller to trigger a JQuery function

Having searched through numerous posts, I was unable to find a specific discussion on integrating a Web API Controller into the MVC Framework. Therefore, I decided to create a post addressing this topic. In my case, I am working with C# and my controller ...

Discover the ultimate guide to harmonize IE 9 with the ingenious Bootstrap Multiselect plugin developed by davidstutz

I've come across an amazing plug-in developed by David Stutz that allows for a Bootstrap and jQuery multi-select options list. Here are some resources: Check out the source code on Github Find documentation and examples here This plug-in works fla ...

Viewing all album titles simultaneously using the Flickr API

After trying a different approach due to lack of responses to my previous question, I am still facing the same issue. My code successfully retrieves all album names and corresponding photos from Flickr API, but it displays all album names at once followed ...

Utilizing the CSS 'overflow: hidden' property and jQuery to restrict users from scrolling during a loading page

OBJECTIVE I aim to restrict the user from scrolling while the page is loading. ISSUE The snippet of code provided successfully prevents the user from scrolling during the additional 2 seconds of the loader animation: $('body').toggleClass(&ap ...

Implementing a Radial Cursor with a Custom Background Image in JavaScript

I am attempting to implement a radial cursor on a website that features a background image. Currently, I am facing two main issues: The radial cursor works in Chrome but not in Firefox. When using Firefox, I encounter a parsing error related to the "bac ...

The jQuery load() method may not load all elements

I've been struggling with a query issue for quite some time now. I have a Content Management System that I want to integrate into my website, but unfortunately, I am unable to use PHP includes. As an alternative, I decided to utilize jQuery instead. D ...

Displaying search results seamlessly on the same page without any need for reloading

I am looking to create a search engine that displays results without the need to refresh the page. I have come across using hash as a potential solution, but I don't have much knowledge about web programming. So far, with the help of tutorials, I have ...

The installation of @types/jquery leads to an unnecessary global declaration of $

In my package.json file, I have the following dependencies defined: { "dependencies": { "@types/jquery": "^3.5.5", } } This adds type declarations through @types/jquery/misc.d.ts, including: declare const jQuery: JQue ...

Utilize a single CDN or multiple CDNs to access and retrieve files

When I visit a standard webpage, I usually load the following resources from various CDNs: jQuery Angular Bootstrap Icomoon several Angular plugins Would it be more efficient to load all these resources from a single CDN, or is it fine to use multiple ...