牛腩新闻发布系统之HTTP错误403.14

在敲牛腩新闻发布系统的时候,在向类别新闻类写入姓名的时候出现了错误,下面先来看看我的代码:

U层

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;

namespace 牛腩新闻发布系统
{
    public partial class Web : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Write(SQLhelper.test());
        }
    }
}
由于测试功能之间的实现,所以没有加上B层,直接引用的D层。而且由于功能简单没有加上相应注释,大家谅解!

D层:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;

namespace DAL
{
    public class SQLhelper
    {
        public static int test()
        {
            string connStr = "server=192.168.24.100;database=newssystem;uid=sa;pwd=123456";
            SqlConnection conn = new SqlConnection(connStr);
            conn.Open();
            string sql = "insert into  category(name)values('徐志鹏')";
            SqlCommand cmd = new SqlCommand(sql, conn);
            int result = cmd.ExecuteNonQuery();
            conn.Close();
            return result;
        }
       
    }
}
运行,调试:错误如下:

  

下面我来说说关于这样问题的解决方法!

打开 IIS管理器。

在“功能”视图中,双击“目录浏览”。

在“目录浏览”页上,在“操作”窗格中单击“启用”。

确认站点或应用程序配置文件中的 configuration/system.webServer/directoryBrowse@enabled 特性被设置为 True

  大家会问IIS是什么?怎么打开它呢?

IIS百度百科大家可以通过链接查看IIS的详解。

我主要来解释一下关于打开IIS,注意我的系统是win7 64位的

。“开始”》“控制面板”—》“程序”[PS:查看方式为“类别”才有该选项,否则为“程序和功能]——》”打开或关闭Windows功能”——》选择“Internet信息服务”按确定后将会安装IIS,安装过程结束后要重启计算机!

   然后选择管理工具:

选择信息服务IIS管理器:


双击“默认文档”,打开后点击右边的“添加”,添加自己项目的默认的文档就可以,添加后就可以正常运行了!

运行结果界面会显示“1”,然后数据库对应的写入信息:


总结是学习的必经之路,即使简简单单的错误也要记录下来,算是自己的一种成长吧!

                                                如有建议或者意见,欢迎大家踊跃拍砖!




  

原文地址:https://www.cnblogs.com/xzpblog/p/5117977.html