错误您要查找的资源(或其中一个依赖项)可能已被删除 [英] error The resource you are looking for (or one of its dependencies) could have been removed

查看:91
本文介绍了错误您要查找的资源(或其中一个依赖项)可能已被删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI
它是我在ViewNews中的控制器:

私有NezamDB db = new NezamDB(); 
PersianCalendar persian = new PersianCalendar();
NewsViewModel Mod;
//
// GET:/ ViewNews /
[HttpGet]
public ActionResult Index(int id)
{
某些代码是隐藏的... ..


var model =(来自r中的db.News.AsEnumerable()
其中r.Id == id
选择新的NewsViewModel
{
Body = r.Body,
Comments = r.Comments,
Education = r.Education,
Financial = r.Financial,
Id = r.Id ,
ImageUrl = r.ImageUrl,
Notic = r.Notic,
Public = r.Public,
Refahi = r.Refahi,
Special = r.Special ,
摘要= r.Summary,
Title = r.Title,
访客= r.Visitors,
CreateDate =((persian.GetYear(r.CreateDate)+/+ persian.GetMonth(r.CreateDate)+/+ persian.GetDayOfMonth(r。 CreateDate))),
UpdateDate =((persian.GetYear(r.UpdateDate)+/+ persian.GetMonth(r.UpdateDate)+/+ persian.GetDayOfMonth(r.UpdateDate)))
})。SingleOrDefault();
string s =;
if(model == null)
{
return HttpNotFound();
}
其他
{
Mod = new NewsViewModel();
Mod.Id = model.Id;
Mod.ImageUrl = model.ImageUrl;
Mod.Notic = model.Notic;
Mod.Public = model.Public;
Mod.Refahi = model.Refahi;
Mod.Special = model.Special;
Mod.Summary = model.Summary;
Mod.Title = model.Title;
Mod.UpdateDate = model.UpdateDate;
Mod.Visitors = model.Visitors;
s = model.Body;
Mod.Body = s.Replace(\ n,<+br /+>);
Mod.Comments = model.Comments;
Mod.CreateDate = model.CreateDate;
Mod.Education = model.Education;
Mod.Financial = model.Financial;


}
访客访问=新访客();
visit.Name = visitorIPAddress.ToString();
visit.NewsId = id;
db.Visitors.Add(访问);
db.SaveChanges();

return View(Mod);

}


protected override void Dispose(bool disposing)
{
db.Dispose();
base.Dispose(disposing);
}





它是查看:

 @ model NewsViewModel 


@ {
ViewBag.Title =مشاهدهخبر;
}

<! - ################################################## ################################################## ##### - >
< h1 > @ Model.Title < / h1 >
< span > تاریخایجاد:@ Model.CreateDate < / span > |
< span > تاریخآخرینویرایش:@ Model.UpdateDate < / span > |
< span > تعدادبازدید:@ Model.Visitors.Count()< / span >
< hr / >
< br / >
< img class = imgr src = @ Model.ImageUrl / >
@ Html.Raw(System.Web .HttpUtility.HtmlDecode(@ Model.Body))

<! - ########################################## ################################################## ########### - >


@ Html.Partial(_ Index,Model.Comments)
@ * @ Html.Partial(_ IndexSendCommend,new {model = new Comments()} .model)* @
@ Html.Action( 创建,评论,新{NewsId = Model.Id})



它是局部视图:

 @ model IEnumerable <  评论 >  
< div id = 评论 >
< hr / >
< br / >
< h2 > نظراتارسالشده< / h2 >
< ul < span class =code-attribute> class = commentlist >
@foreach(模型中的var项目)
{
if(( item.Id%2)== 0)
{
< li class = comment_odd >
< div class = 作者 >
< img class = 头像 src = 〜/ images / demo / avatar.gif width = 32 < span class =code-attribute> height = 32 alt = / < span class =code-keyword>> < span class = 写道 > نویسنده:< / span > < span class = 名称 > @ item.Name < / span >
< / div >
< div class = submitdate > < a href = > @ item.DateCreat < / a > < / div >
@ {
string s = @ item.Body;
s = s.Replace(\ n,< + br / + > );
< p > @ Html.Raw(System.Web.HttpUtility.HtmlDecode(s))< / p < span class =code-keyword>>
}
< / li >
}
else
{
< li class = comment_even >
< div = 作者 >
< img class = avatar src = 〜/ images / demo / avatar.gif width = 32 height = 32 alt = < span class =code-attribute> / > < span class = 写道 > نویسنده:< / span > < span class = name > < a href = > @ item.Name < / a > < / span >
< / div >
< < span class =code-leadattribute> div class = submitdate > < a href = > @ item.DateCreat < / a > < / div >
@ {
string s = @ item.Body;
s = s.Replace(\ n,< + br / + > );
< p > @ Html.Raw(System.Web.HttpUtility.HtmlDecode(s))< / p < span class =code-keyword>>
}
< / li >
}
}
< / ul >
< / div >





它是控制器动作链接命令:

  //  < span class =code-comment>  
// GET :/ Comment / Create
[HttpGet]
[ValidateInput( false )]
public ActionResult Create( int NewsId)
{


return PartialView();
}

//
// POST:/ Comment / Create

[HttpPost]
[ValidateInput ( false )]
public ActionResult Create(评论评论)
{
// string st = HttpContext.Session [captcha]。ToString();
// if(st ==1)
{
comments.DateCreat = DateTime.Now.ToShortDateString();
if (ModelState.IsValid)
{

db.Comments.Add(comments);
db.SaveChanges();
ModelState.Clear();

ControllerContext.HttpContext.Response.Redirect(Request.UrlReferrer.ToString());
}
}
// else
< span class =code-comment> // {
// ModelState.AddModelError(Cap,مقدارباتصویربرابرنیست);

/ / }
return PartialView();
}



它是view'command

 @ model Nezam。 Models.Comments 

@ {
ViewBag.Title =Create;
}

< h2 > ارسالنظرات< / h2 >

@using(Html.BeginForm())
{
@ Html.ValidationSummary(true)

< fieldset class = fieldset >
< 图例 class = legend > ارسالنظر< / legend >

< p >
@ Html.LabelFor(model = > model.Name)
@ Html.EditorFor(model => model.Name,new {Size =22})
@ Html.ValidationMessageFor(model => model.Name)

< / p >

< p >
@ Html.LabelFor(model => model.Email,new {Style =margin-left:52px})
@ Html.EditorFor(model => ; model.Email,new {Size =22})
@ Html.ValidationMessageFor(model => model.Email)

< ; / p >
< p >
@ Html.LabelFor(mode l => model.Body)
< / p >
< p >
@ Html.TextAreaFor(model => model.Body,new {cols =100%,rows =10})
@ Html.ValidationMessageFor(model => model.Body)

< / p >

< p >
< input type = 提交 value = ارسال / >
< / p >
< / fieldset >
}


$ section Scripts {

}





i运行我的项目,我看到我的页面'viewnews但当我点击提交按钮在行动链接在命令局部视图给我这个错误:



'/'应用程序中的服务器错误。 
无法找到资源。
描述:HTTP 404.您要查找的资源(或其中一个依赖项)可能已被删除,名称已更改或暂时不可用。请查看以下网址,确保拼写正确。

请求的URL:/ ViewNews / Index / 3012

版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.0.30319.34009





我在properties-> web-> specificpage中设置起始页面URL。 />


它抛出了上面提到的错误。



我找不到这个问题背后的原因。当我尝试访问cshtml页面时,它工作正常。



请帮我解决问题

解决方案

< blockquote> hi
哦,我的上帝

什么是大错误

这个错误是由于我的[HttpGet]使用了

并且[HttpPost]没有定义


HI it is my Controller in ViewNews :

private NezamDB db = new NezamDB();
       PersianCalendar persian = new PersianCalendar();
       NewsViewModel Mod;
       //
       // GET: /ViewNews/
       [HttpGet]
       public ActionResult Index(int id)
       {
          some code is hiden....


           var model = (from r in db.News.AsEnumerable()
                        where r.Id==id
                        select new NewsViewModel
                        {
                            Body = r.Body,
                            Comments = r.Comments,
                            Education = r.Education,
                            Financial = r.Financial,
                            Id = r.Id,
                            ImageUrl = r.ImageUrl,
                            Notic = r.Notic,
                            Public = r.Public,
                            Refahi = r.Refahi,
                            Special = r.Special,
                            Summary = r.Summary,
                            Title = r.Title,
                            Visitors = r.Visitors,
                            CreateDate = ((persian.GetYear(r.CreateDate) + "/" + persian.GetMonth(r.CreateDate) + "/" + persian.GetDayOfMonth(r.CreateDate))),
                            UpdateDate = ((persian.GetYear(r.UpdateDate) + "/" + persian.GetMonth(r.UpdateDate) + "/" + persian.GetDayOfMonth(r.UpdateDate)))
                        }).SingleOrDefault();
           string s="";
           if (model == null)
           {
               return HttpNotFound();
           }
           else
           {
               Mod = new NewsViewModel();
               Mod.Id = model.Id;
               Mod.ImageUrl = model.ImageUrl;
               Mod.Notic = model.Notic;
               Mod.Public = model.Public;
               Mod.Refahi = model.Refahi;
               Mod.Special = model.Special;
               Mod.Summary = model.Summary;
               Mod.Title = model.Title;
               Mod.UpdateDate = model.UpdateDate;
               Mod.Visitors = model.Visitors;
               s=model.Body;
               Mod.Body = s.Replace("\n", "<" + "br/" + ">");
               Mod.Comments = model.Comments;
               Mod.CreateDate = model.CreateDate;
               Mod.Education = model.Education;
               Mod.Financial = model.Financial;


           }
           Visitors visit = new Visitors();
           visit.Name = visitorIPAddress.ToString();
           visit.NewsId = id;
           db.Visitors.Add(visit);
           db.SaveChanges();

           return View(Mod);

       }


       protected override void Dispose(bool disposing)
       {
           db.Dispose();
           base.Dispose(disposing);
       }



and it is View :

@model NewsViewModel


@{
    ViewBag.Title = "مشاهده خبر";
}

<!-- ####################################################################################################### -->
<h1>@Model.Title</h1>
<span>تاریخ ایجاد: @Model.CreateDate</span> |
            <span>تاریخ آخرین ویرایش: @Model.UpdateDate</span> |
            <span>تعداد بازدید: @Model.Visitors.Count()</span>
<hr />
<br />
<img class="imgr" src="@Model.ImageUrl" />
@Html.Raw(System.Web.HttpUtility.HtmlDecode(@Model.Body))

<!-- ####################################################################################################### -->


@Html.Partial("_Index", Model.Comments)
@*@Html.Partial("_IndexSendCommend", new {model=new Comments() }.model)*@
@Html.Action("create", "Comment", new { NewsId = Model.Id })


it is partial view :

@model IEnumerable<Comments>
<div id="comments">
     <hr />  
     <br />
    <h2>نظرات ارسال شده</h2>
    <ul class="commentlist">
        @foreach (var item in Model)
        {
            if ((item.Id % 2) == 0)
            {
            <li class="comment_odd">
                <div class="author">
                    <img class="avatar" src="~/images/demo/avatar.gif" width="32" height="32" alt="" /><span class="wrote">نویسنده:</span><span class="name">@item.Name</span> 
                </div>
                <div class="submitdate"><a href="#">@item.DateCreat</a></div>
                @{
                string s = @item.Body;
                s = s.Replace("\n", "<" + "br/" + ">");
                <p>@Html.Raw(System.Web.HttpUtility.HtmlDecode(s))</p>
                }
            </li>
            }
            else
            {
            <li class="comment_even">
                <div class="author">
                    <img class="avatar" src="~/images/demo/avatar.gif" width="32" height="32" alt="" /><span class="wrote">نویسنده:</span><span class="name"><a href="#">@item.Name</a></span> 
                </div>
                <div class="submitdate"><a href="#">@item.DateCreat</a></div>
                @{
                string s = @item.Body;
                s = s.Replace("\n", "<" + "br/" + ">");
                <p>@Html.Raw(System.Web.HttpUtility.HtmlDecode(s))</p>
                }
            </li>
            }
        }
    </ul>
</div>



it is controller in action link command:

//
       // GET: /Comment/Create
       [HttpGet]
       [ValidateInput(false)]
       public ActionResult Create(int NewsId)
       {


           return PartialView();
       }

       //
       // POST: /Comment/Create

       [HttpPost]
       [ValidateInput(false)]
       public ActionResult Create(Comments comments)
       {
           //string st = HttpContext.Session["captcha"].ToString();
           //if (st == "1")
           {
               comments.DateCreat = DateTime.Now.ToShortDateString();
               if (ModelState.IsValid)
               {

                   db.Comments.Add(comments);
                   db.SaveChanges();
                   ModelState.Clear();

                   ControllerContext.HttpContext.Response.Redirect(Request.UrlReferrer.ToString());
               }
           }
           //else
           //{
           //    ModelState.AddModelError("Cap", "مقدار با تصویر برابر نیست");

           //}
           return PartialView();
       }


and it is view'command

@model Nezam.Models.Comments

@{
    ViewBag.Title = "Create";
}

<h2>ارسال نظرات </h2>

@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)

    <fieldset class="fieldset">
        <legend class="legend">ارسال نظر</legend>

        <p>
            @Html.LabelFor(model => model.Name)
            @Html.EditorFor(model => model.Name, new { Size = "22" })
            @Html.ValidationMessageFor(model => model.Name)
          
        </p>

        <p>
            @Html.LabelFor(model => model.Email,new { Style = "margin-left:52px" })
            @Html.EditorFor(model => model.Email, new { Size = "22" })
            @Html.ValidationMessageFor(model => model.Email)
            
        </p>
        <p>
            @Html.LabelFor(model => model.Body)
            </p>
        <p>
            @Html.TextAreaFor(model => model.Body, new { cols = "100%", rows = "10" })
            @Html.ValidationMessageFor(model => model.Body)

        </p>
        
        <p>
            <input type="submit" value="ارسال" />
        </p>
    </fieldset>
}


@section Scripts {
   
}



i run my project and i see my page' viewnews but when i click on submit button in action link in command partial view give me this error :

Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.

Requested URL: /ViewNews/Index/3012

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34009 



I set the starting page URL in properties->web->specificpage.

It throws me the above mentioned error.

I couldnt find the reason behind this issue. When i try to access the cshtml page it works fine.

Please help me to overcome the issue

解决方案

hi oh my god
What was a big mistake
This error was due to my [HttpGet] had used
And [HttpPost] did not define


这篇关于错误您要查找的资源(或其中一个依赖项)可能已被删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆