IIS网页在按“提交”按钮(POST请求)时返回“服务器错误500”

问题描述 投票:0回答:1

我正在使用Django框架为我的团队创建简单的Web门户。 Web门户的主要目的是使用paramiko.SSHClent()将文件传送到服务器。如果我使用“ python manage.py runserver”在本地服务器上运行项目,则按“提交”按钮会将文件从用户传递到服务器。

下一步是部署网站。因此,我使用Windows Internet信息服务(IIS)管理器8.5部署了我的网站。网站已部署,但是存在一个问题。如果我按“提交”按钮,则会收到此错误,“服务器错误(500)”

这里是详细错误图像:500 Server Error Detail IMAGE

这里是views.py文件:

    from django.shortcuts import render, redirect
    from .forms import DocumentForm
    from django.contrib import messages
    import paramiko
    import os
    from . import file_mapping


    def uploadForm(request):

    if request.method == 'POST':
    form = DocumentForm(request.POST, request.FILES)
    if form.is_valid():
        form.save()

        document = request.FILES['document']
        client_name = form.cleaned_data.get('client')
        file_type = form.cleaned_data.get('fileType')
        print('Client Name: ' + client_name)
        print('File Type: ' + file_type)

        file_mapping.handle_uploaded_file(document)
        file_mapping.setupfilename(client_name, file_type)
        #file_mapping.connectCqaServer(document)


        messages.success(request, f'Your file has been uploaded.')

    else:
        form = DocumentForm()
        #messages.warning(request, f'Your file is Invalid')

    return render(request, 'forms/forms.html', {'form': form}) 

这里是forms.html文件:

    {% extends "blog/base.html"%}
    {% load crispy_forms_tags %} 
    {% block content %}
    <div class="content-section">
     <form method="POST" enctype="multipart/form-data">
         {% csrf_token %}
         <fieldset class="form-group">
             <legend class="border-bottom mb-4"> Upload Name and File </legend>
             {{ form | crispy }}
         </fieldset>

         <div class="form-group">
             <button class="btn btn-outline-info" type="submit">Upload</button>
         </div>
     </form>
    </div>
    {%endblock content %}

这里是IIS管理器上的处理程序映射设置:HANDLER MAPPING IMAGE LINK

这里是IIS日志

    2020-05-06 18:23:52 10.137.11.223 POST /forms/ - 80 - 10.25.75.1 
    Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+ 
    (KHTML,+like+Gecko)+Chrome/81.0.4044.129+Safari/537.36 
    http://spscvt.com/forms/ 500 0 0 164

我没有安装WEBDAV

有人可以帮忙解决这个问题吗?从我的在线研究中,我发现IIS不允许使用POST方法,但是我不知道要删除POST限制。

谢谢

django iis http-post web-deployment server-error
1个回答
0
投票

Microsoft IIS创建了一个称为AppPool的东西。默认情况下,您将有一个用户IIS AppPool\DefaultAppPool。该用户需要具有数据库和其他必要文件的权限才能读取写入。

如果不这样做,将返回500错误。您可以在此处查看此剪辑,以了解如何解决错误Django on IIS with 500 error

为了授予权限,您可以按照以下步骤操作

  1. 右键单击Django项目文件夹

  2. 属性->安全

  3. 编辑->添加:IIS AppPool\DefaultAppPool或您正在使用的任何应用程序池

  4. 重新启动服务器并再次测试

© www.soinside.com 2019 - 2024. All rights reserved.