Mvc Route Hatası

2,960 views
Skip to first unread message

Rasim Kaptan

unread,
Dec 12, 2013, 3:52:22 AM12/12/13
to altdotne...@googlegroups.com

Merhaba,


Mvc 4 route hata almaktayım.


Views Klasörüm Şu Şekilde :

Views/Service/Sigorta/Index.cshtml


Controller Klasörüm :

Controller /Service / Sigorta / SigortaController


Route Ayarım :

            routes.MapRoute(
                name: "Sigorta",
                url: "Service/{controller}/{action}/{id}",
                defaults: new { controller = "Sigorta", action = "Index", id = UrlParameter.Optional }
);

Aldığım Hata : 

'/' 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: /Service/Sigorta/Index


Cem LEGOZ

unread,
Dec 12, 2013, 4:40:06 AM12/12/13
to altdotne...@googlegroups.com

MapRoute'da namespace parametresi Sigorta route'u için eksik gibi.

--
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 http://groups.google.com/group/altdotnetturkiye.
For more options, visit https://groups.google.com/groups/opt_out.

Rasim Kaptan

unread,
Dec 12, 2013, 5:41:05 AM12/12/13
to altdotne...@googlegroups.com
Yani Bu Şekilde mi ?

Route Ayarım :

            routes.MapRoute(
                name: "Sigorta",
                url: "Service/Sigorta/{controller}/{action}/{id}",

Bayram Akbuz

unread,
Dec 12, 2013, 5:54:34 AM12/12/13
to altdotne...@googlegroups.com

Controler altına service klasörü oluşturmaniza gerek yok. Olustursaniz bile klasör ismini bağlantı adresine yazmadan erişilebilirsiniz. Service çok karmaşık ise Service isimli 'area' oluşturmak daha mantıklı.

Bu halde devam etmek istiyor iseniz routemap te belirlemeniz gerekiyor.

12 Ara 2013 12:41 tarihinde "Rasim Kaptan" <rasim.k...@gmail.com> yazdı:

Rasim Kaptan

unread,
Dec 12, 2013, 6:14:34 AM12/12/13
to altdotne...@googlegroups.com
Route ayarını belirttiğim halde o sayfaya ulaşmıyorum  ben bütün controller klasörlerini kaldırdım. lakin o sayfaya ulaşamıyorum.

12 Aralık 2013 Perşembe 12:54:34 UTC+2 tarihinde Bayram Akbuz yazdı:

Ahmet Arslan

unread,
Dec 12, 2013, 10:32:30 AM12/12/13
to altdotne...@googlegroups.com
Controller Klasörüm :

Controller /Service / Sigorta / SigortaController

bu satırdaki Sigorta klasörünü kaldırıp dener misin? SigortaController.cs dosyasını bir üst klasöre alabilirsin denemek için.

Bayram Akbuz

unread,
Dec 12, 2013, 10:55:39 AM12/12/13
to altdotne...@googlegroups.com
Controller altına istenildiği kadar klasör ve alt klasör oluşturmanız sadece sınıflarınızı derli toplu kalmasını sağlar.

Controller\SigortaController
Controller\Service\SigortaController
Controller\Service\Sigorta\SigortaController
XYZ\Service\Sigorta\SigortaController

yukarıdaki controller'ların 'Ekle' metoduna erişmek için bağlantı aşağıdaki gibi olacaktır.


Views klöasürü ise yuıkarıdakilerden hangisi kullanılırsa kullanılsın aşağıdaki gibi olmalıdır.
Views\Sigorta\Ekle.cshtml



Aslında işin özü şu: SigortaController sınıfı Controller sınıfından türemekte. Bu nedenle ister controller klasörü, ister onun altında iç içe klasörler isterse de controller değilde farklı bir klasör altında tutulsun durum değişmeyecektir. Sadece namespace değişir. MapRoute yapılandırması ve Views klasörü bu durumdan etkilenmezler. 

Rasim Kaptan

unread,
Dec 12, 2013, 11:59:17 AM12/12/13
to altdotne...@googlegroups.com
benim Sıkıntım onunla ilgili değil lakin ,

Views klasör yapım şu şekilde :

Views/ Service / Sigorta / Index.cshtml

Bunu SigortaController.cs ile Index sayfasına ulaşamıyorum.



12 Aralık 2013 Perşembe 17:55:39 UTC+2 tarihinde Bayram Akbuz yazdı:

Fikret AKIN

unread,
Dec 12, 2013, 12:09:10 PM12/12/13
to altdotne...@googlegroups.com
Controller içindeki index üzerinde sağ tık yapıp add view yaparak deneyebilirmisin?
eğer öylede çalışmıyorsa route kısmında;


routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );

bunun olduğuna dikkat et, eğer var sa da hale çalışmıyorsa başka route kuralları ile çakışıyor olabilir.


12 Aralık 2013 18:59 tarihinde Rasim Kaptan <rasim.k...@gmail.com> yazdı:

--
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 http://groups.google.com/group/altdotnetturkiye.
For more options, visit https://groups.google.com/groups/opt_out.



--
 

 

İyi Çalışmalar,

 

Fikret AKIN

GSM: 0534 700 75 19
Personal web: www.fikretakin.com

Bayram Akbuz

unread,
Dec 12, 2013, 12:39:52 PM12/12/13
to altdotne...@googlegroups.com
Views/ Service / Sigorta / Index.cshtml 

Service klasürü olmaması gerekiyor. Views/Sigorta/Index.cshtml şeklinde olmalı. bunun dışında halen daha hata alıyorsan route ile ilgili bir sorunun var. 

ayrıca 'Area' oluşturarak yapmak istediğini daha rahat yapabilirsiniz. 

Harun Yigit LEGOZ

unread,
Dec 12, 2013, 1:21:15 PM12/12/13
to altdotne...@googlegroups.com
Bu routedan baska rotu var mi? Bundan onceki bir route bunu eziyor olabilir mi? Default falan?
--
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 http://groups.google.com/group/altdotnetturkiye.
For more options, visit https://groups.google.com/groups/opt_out.


--

Onur DEMİREL

unread,
Dec 13, 2013, 8:31:00 AM12/13/13
to altdotne...@googlegroups.com
Selamlar,
Service adında bir area oluşturmak daha doğru olacaktır.Ancak yok ben area olmasını istemiyorum dersen, ViewEngine default pathlerini ezmelisin :) 
Aşağıdaki kullanım sorununu çözecektir.



Global.asax
            ViewEngines.Engines.Clear();
            var viewEngine = new CustomViewLocationRazorViewEngine();
            ViewEngines.Engines.Add(viewEngine);



  public class CustomViewLocationRazorViewEngine : RazorViewEngine
    {
        public CustomViewLocationRazorViewEngine()
        {


            AreaViewLocationFormats = new[]
                                          {
                                  
                                              //default
                                              "~/Areas/{2}/Views/{1}/{0}.cshtml", 
                                              "~/Areas/{2}/Views/{1}/{0}.vbhtml", 
                                              "~/Areas/{2}/Views/Shared/{0}.cshtml", 
                                              "~/Areas/{2}/Views/Shared/{0}.vbhtml",

                                              "~/{2}/Views/{1}/{0}.cshtml",
                                              "~/{2}/Views/{1}/{0}.vbhtml",
                                              "~/{2}/Views/Shared/{0}.cshtml",
                                              "~/{2}/Views/Shared/{0}.vbhtml",




                                          };

            AreaMasterLocationFormats = new[]
                                            {
                                            
                                                //default
                                                "~/Areas/{2}/Views/{1}/{0}.cshtml", 
                                                "~/Areas/{2}/Views/{1}/{0}.vbhtml", 
                                                "~/Areas/{2}/Views/Shared/{0}.cshtml", 
                                                "~/Areas/{2}/Views/Shared/{0}.vbhtml"
                                            };

            AreaPartialViewLocationFormats = new[]
                                                 {
                                                    
                                                    
                                                //default
                                                "~/Areas/{2}/Views/{1}/{0}.cshtml", 
                                                "~/Areas/{2}/Views/{1}/{0}.vbhtml", 
                                                "~/Areas/{2}/Views/Shared/{0}.cshtml", 
                                                "~/Areas/{2}/Views/Shared/{0}.vbhtml"
                                                 };

            ViewLocationFormats = new[]
                                      { 

                                            //default
                                            "~/Views/{1}/{0}.cshtml", 
                                            "~/Views/{1}/{0}.vbhtml", 
                                            "~/Views/Shared/{0}.cshtml",
                                            "~/Views/Shared/{0}.vbhtml",
 
                                            //Service
                                            "~/Service/Views/{1}/{0}.cshtml",
                                            "~/Service/Views/{1}/{0}.vbhtml",
                                            "~/Service/Views/Shared/{0}.cshtml",
                                            "~/Service/Views/Shared/{0}.vbhtml",

                                         
 
                                             
                                      };

            MasterLocationFormats = new[]
                                        {
                                          //default
                                            "~/Views/{1}/{0}.cshtml", 
                                            "~/Views/{1}/{0}.vbhtml", 
                                            "~/Views/Shared/{0}.cshtml", 
                                            "~/Views/Shared/{0}.vbhtml"
                                        };

            PartialViewLocationFormats = new[]
                                             {
                                              
                                                //default
                                                "~/Views/{1}/{0}.cshtml", 
                                                "~/Views/{1}/{0}.vbhtml", 
                                                "~/Views/Shared/{0}.cshtml", 
                                                "~/Views/Shared/{0}.vbhtml",
 
                                                  //Service
                                                "~/Service/Views/{1}/{0}.cshtml",
                                                "~/Service/Views/{1}/{0}.vbhtml",
                                                "~/Service/Views/Shared/{0}.cshtml",
                                                "~/Service/Views/Shared/{0}.vbhtml",

                                                
                                               

                                             };

            FileExtensions = new[] { "cshtml", "vbhtml" };






        }
    }



12 Aralık 2013 20:21 tarihinde Harun Yigit LEGOZ <hyl...@gmail.com> yazdı:

Rasim Kaptan

unread,
Dec 16, 2013, 12:46:48 PM12/16/13
to altdotne...@googlegroups.com
çok teşekkür ederim yardımlarınız için

13 Aralık 2013 Cuma 15:31:00 UTC+2 tarihinde Onur Demirel yazdı:
To unsubscribe from this group and stop receiving emails from it, send an email to altdotnetturkiye+unsubscribe@googlegroups.com.
To post to this group, send email to altdotnetturkiye@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages