MVC BLOG Parametre Hatası ?

1,204 views
Skip to first unread message

Ersoy kbc

unread,
Jan 10, 2016, 11:47:19 AM1/10/16
to altdotnetturkiye
oluşturmuş olduğum controller da bu hatayı almaktayım

The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Index(Int32)' in 'bLOGYAPİMİ.Controllers.CategoryController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
Parametre adı: parameters


Controoler içerisinde olan kodum ise şu anlık

using bLOGYAPİMİ.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace bLOGYAPİMİ.Controllers
{
    public class CategoryController : BaseController
    {
        //
        // GET: /Category/
        AvengersBlogEntities db = new AvengersBlogEntities();
        public ActionResult Index(int id)
        {
            return View(db.Articles.Where(x => x.CategoryID == id).ToList());
        }

    }
}

Burada olan hata  visual s içerisinde controllarda olan index dosyasına tıkladığımda lmaktayım lakin 


Home controller içerisinde olan index e tıkladığımda ise

sayfa normal acılıyor ama

categori kısmına gçtiğim zaman ise anında şu hatayı almkatayım


'/' Uygulamasında Sunucu Hatası.

Kaynak bulunamadı.

Açıklama: HTTP 404. Aradığınız kaynak (veya bağımlı olduklarından biri) kaldırılmış, adı değiştirilmiş veya geçici olarak kullanılamaz durumda olabilir. Lütfen aşağıdaki URL'yi gözden geçirin ve doğru yazıldığından emin olun. 

İstenen URL: /Category/İndex/1


Sürüm Bilgisi: Microsoft .NET Framework Sürümü:4.0.30319; ASP.NET Sürümü:4.0.30319.34274




Sorun neden kaynaklanıyor neyi boş geçtim veya neyi eksik belirttim ?

özgür akdoğan

unread,
Jan 10, 2016, 6:02:59 PM1/10/16
to altdotnetturkiye
Merhaba

@url.action("sinif/actionresult/",new{id=1})

Html tarafta bu sekilde istek yaparsan olmasi lazim

Berat Çarşı

unread,
Jan 11, 2016, 3:58:48 PM1/11/16
to altdotnetturkiye
yanlış görmüyorsam istek İndex'e yapılmış. yani türkçe büyük i yazılmış :) Index olursa sorun olmayacaktır.


10 Oca 2016 Paz, 18:03 tarihinde, özgür akdoğan <ozgur...@gmail.com> şunu yazdı:
Merhaba

@url.action("sinif/actionresult/",new{id=1})

Html tarafta bu sekilde istek yaparsan olmasi lazim

--
You received this message because you are subscribed to the Google Groups "altdotnetturkiye" group.
To unsubscribe from this group and stop receiving emails from it, send an email to altdotnetturki...@googlegroups.com.
To post to this group, send email to altdotne...@googlegroups.com.
Visit this group at https://groups.google.com/group/altdotnetturkiye.
For more options, visit https://groups.google.com/d/optout.

Erdal Çetin

unread,
Jan 13, 2016, 5:45:25 AM1/13/16
to altdotne...@googlegroups.com
 public ActionResult Index(int id)
        {
            return View(db.Articles.Where(x => x.CategoryID == id).ToList());
        }



bir an için id parametresine değer gelmediğini düşünün.. sorgu ne olurdu?  !!!!! bingo !!!'!'^+%&/  => patlar tabi...

 public ActionResult Index(int id)
        {
if(id!=null)
{
           return View(db.Articles.Where(x => x.CategoryID == id).ToList());
}else{
          // ToDo
}
 
        }



Harun LEGOZ

unread,
Jan 13, 2016, 1:34:26 PM1/13/16
to altdotne...@googlegroups.com
Id nullable değil yalnız, normal integer. Ayrıca id ye değer gelmezse routing baştan patlar zaten.
Harun Legoz
Reply all
Reply to author
Forward
0 new messages