• 1396/12/22

حذف آدرس ها در MVC :

با سلام.

چطور میتونم پسوند های غیر از cshtml رو توی MVC حذف کنم. ممنونم میشم راهنمایی کنید.

  • 1396/12/23
  • ساعت 08:58

منظورتون رو متوجه نشدم


  • 1396/12/23
  • ساعت 09:12

برای مثال یه اکشنی که ویو نداره وقتی اجرا میشه مثلا این آدرس ها پیدا نشد:

view/home/index.cshtm

view/home/index.vbhtm

view/home/index.aspx

یه کاری کنیم که دیگه دنبال اینا به جز cshtml نگرده


  • 1396/12/23
  • ساعت 09:16

کلاس زیر را بعنوان ViewEngin معرفی کنید

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace ClearEnginVB_MVC.App_Start
{
    public class CSharpRazorViewEngine : RazorViewEngine
    {
        public CSharpRazorViewEngine()
        {
            AreaViewLocationFormats = new[]
    {
    "~/Areas/{2}/Views/{1}/{0}.cshtml",
    "~/Areas/{2}/Views/Shared/{0}.cshtml"
    };
            AreaMasterLocationFormats = new[]
    {
    "~/Areas/{2}/Views/{1}/{0}.cshtml",
    "~/Areas/{2}/Views/Shared/{0}.cshtml"
    };
            AreaPartialViewLocationFormats = new[]
    {
    "~/Areas/{2}/Views/{1}/{0}.cshtml",
    "~/Areas/{2}/Views/Shared/{0}.cshtml"
    };
            ViewLocationFormats = new[]
    {
    "~/Views/{1}/{0}.cshtml",
    "~/Views/Shared/{0}.cshtml"
    };
            MasterLocationFormats = new[]
    {
    "~/Views/{1}/{0}.cshtml",
    "~/Views/Shared/{0}.cshtml"
    };
            PartialViewLocationFormats = new[]
    {
    "~/Views/{1}/{0}.cshtml",
    "~/Views/Shared/{0}.cshtml"
    };
        }
    }
}

 


logo-enamadlogo-samandehi