RedirectToAction / CanvasRedirectToAction Giving 404 Error Because Virtual Directory Name is Repeated in URL
I am just getting started with ASP.Net MV开发者_运维问答C 3 with the Facebook C# SDK. I've had pretty good luck so far, but I am having an issue when returning RedirectToAction or CanvasRedirectToAction in a Controller method.
When I click either the Submit or Create New_ button in the view below, I always get send to /app/app/Event/Create instead of app/Event/Create, resulting in a 404
Thanks in advance!
EventController:
[CanvasAuthorize(Permissions = "user_about_me,user_events,create_event")]
public ActionResult Index()
{
return View();
}
[CanvasAuthorize(Permissions = "user_about_me,user_events,create_event")]
public ActionResult Create()
{
return View();
}
[CanvasAuthorize(Permissions = "user_about_me,user_events,create_event")]
public ActionResult Persist()
{
return this.CanvasRedirectToAction("Index", "Event");
}
Event/Create.cshtml
@using Facebook.Web.Mvc
@model App.Models.Event
@{
ViewBag.Title = "Create";
}
<h2>Create</h2>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"> </script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Html.BeginForm("Persist", "Event")) {
@Html.FacebookSignedRequest();
@Html.ValidationSummary(true)
<fieldset>
<legend>Event</legend>
<div class="editor-label">
@Html.LabelFor(model => model.Name)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
<p>
<input type="submit" value="Create" />
@Html.CanvasActionLink("Create New", "Persist")
</p>
</fieldset>
}
It doesn't appear like it's easily possible. My guess is that the javascript that looks at the URL in the frame within the C# SDK doesn't do a good job of creating the correct path to redirect to. I just got rid of the virtual directory to solve the problem for now.
精彩评论