ASP NET serverime attığımda site hata veriyor

beratzeus

Decapat
Katılım
22 Mart 2020
Mesajlar
25
Merhabalar ben asp net ile site tasarlıyorum fakat kendi bilgisayarımda aynı kodlar yani hata vermiyor fakat sunucuma atıyorum login.aspx uyelikbilgi.aspx ler hata vermezken register.aspx hata veriyor kayıt kısmında fakat kendi bilgisayarımda tıkır tıkır herşey çalışıyor kayıt oluyorum bakıyorum ama sunucum attığımda register.aspx hata veriyor
hata şu şekilde :
Kod:
'/' Uygulamasında Sunucu Hatası.
Nesne başvurusu bir nesnenin örneğine ayarlanmadı.
Açıklama: Geçerli web isteği yürütülürken işlenmemiş özel durum oluştu. Lütfen hata ve kod içinde kaynaklandığı yer hakkında daha fazla bilgi almak için yığın izlemesini gözden geçirin.

Özel Durum Ayrıntıları: System.NullReferenceException: Nesne başvurusu bir nesnenin örneğine ayarlanmadı.

Kaynak Hatası:

Geçerli web isteği yürütülürken işlenmeyen bir özel durum üretildi. Özel durumun kaynağı ve konumuna ilişkin bilgiler aşağıdaki özel durum yığını izlemesi kullanılarak belirlenebilir.

Yığın İzleme:


[NullReferenceException: Nesne başvurusu bir nesnenin örneğine ayarlanmadı.]
   website1.register.Button1_Click(Object sender, EventArgs e) in C:\Users\Berat Ozaydin\source\repos\website1\website1\register.aspx.cs:28
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +11802192
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +149
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1734

register.aspx şu şekilde :
Kod:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="register.aspx.cs" Inherits="website1.register" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .auto-style1 {
            width: 100%;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <table class="auto-style1">
            <tr>
                <td>
                    <asp:Label ID="Label1" runat="server" Text="Kullanici Adi"></asp:Label>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                &nbsp;
                    <asp:TextBox ID="TextBox3" runat="server" style="margin-left: 19px"></asp:TextBox>
                </td>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <td>
  
                    <asp:Label ID="Label2" runat="server" Text="Şifre"></asp:Label>
  
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                  &nbsp  <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                </td>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <td>
                   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <asp:Button ID="Button1" runat="server" Text="Kayıt Ol" OnClick="Button1_Click" />
                </td>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
         
                    </td>
                <td>&nbsp;</td>
            </tr>
        </table>
        <div>
        </div>
    </form>
</body>
</html>

Register.aspx.cs şu şekilde :
Kod:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Data.OleDb;
namespace website1
{
    public partial class register : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            OleDbConnection baglanti = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Server.MapPath("App_Data\\giris1.accdb"));
            
            baglanti.Open();
            OleDbCommand komut = new OleDbCommand(@"insert into kullanici(k_no,k_ad,k_sifre) values(@no,@kullaniciadi,@sifre)", baglanti);
            komut.Parameters.AddWithValue("no", TextBox3.Text);
            komut.Parameters.AddWithValue("kullaniciadi",TextBox1.Text);
            komut.Parameters.AddWithValue("sifre", TextBox2.Text);
            komut.ExecuteNonQuery();
            baglanti.Close();
            Label3.Text = "Kayit Basarili";
            Response.Redirect("login.aspx");
        }
    }
}

Web config de şu şekilde :
Kod:
<?xml version="1.0" encoding="utf-8"?>

<!--
  For more information on how to configure your ASP.NET application, please visit
  https://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.6"/>
    <httpRuntime targetFramework="4.6"/>
  </system.web>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs"
        type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701"/>
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
        type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/>
    </compilers>
  </system.codedom>

</configuration>

NEREDE HATA var acaba
 
Access veritabanı kullanmayalı çok oldu. Fakat dikkatimi çeken şey eğer no dediğiniz şey id numarası ise onu veritabanına otomatik verdirin, siz eklemeyin. Auto gibi basit bir ayarı vardır. Eğer otomatiğe ayarlı ise zaten bu sebepten de hata verir. Yani tavsiyem no bölümünü silin, hem insert sorgusundan hem de parametreden.
 
Uyarı! Bu konu 6 yıl önce açıldı.
Muhtemelen daha fazla tartışma gerekli değildir ki bu durumda yeni bir konu başlatmayı öneririz. Eğer yine de cevabınızın gerekli olduğunu düşünüyorsanız buna rağmen cevap verebilirsiniz.

Technopat Haberler

Yeni konular

Geri
Yukarı