我有个问题.我在MVC 3中有一个名为Page的区域可以正常工作.
我刚刚添加了一个名为Media的新区域,现在我得到了"无法找到该资源"的新区域.我疯了,因为它看起来就像PageArea一样有效.
这里是 MediaAreaRegistration.cs
public override string AreaName
{
get
{
return "Media";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Media_default",
"{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
}
Run Code Online (Sandbox Code Playgroud)
这是我的 global.asax
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
); …Run Code Online (Sandbox Code Playgroud) 嗨,我有一个简单的WCF REST服务,我需要通过querystring获取一些看起来像这样的参数.
页= 1&RP = 10&sortname = ID&排序顺序= ASC&查询=&QTYPE =应用
我的UriTemplate无法正常工作,这里有什么问题?到目前为止只是试图获得页面参数.知道uri应该是什么样的吗?
[OperationContract]
[WebInvoke(Method = "POST",
BodyStyle = WebMessageBodyStyle.WrappedRequest,
ResponseFormat = WebMessageFormat.Json,RequestFormat = WebMessageFormat.Json,
UriTemplate = "/?page={page}")]
[System.Web.Script.Services.ScriptMethod(ResponseFormat = System.Web.Script.Services.ResponseFormat.Json)]
JSONData GetLogList(string page);
Run Code Online (Sandbox Code Playgroud)
这是我的服务代码
public class LogService : ILog
{
[System.Web.Script.Services.ScriptMethod(ResponseFormat = System.Web.Script.Services.ResponseFormat.Json)]
public JSONData GetLogList(string page)
{
var logContext = new LogViewDataContext();
var logsList = from logs in logContext.Logs select logs;
//return logsList.Cast<Log>().ToString();
var baseData = new JSONData();
baseData.page = Int32.Parse(page ?? "1");
baseData.total = logsList.Count();
var cells = new …Run Code Online (Sandbox Code Playgroud) 我试图在视图模型序列化到JSON,但我只拿到undefined的ko.toJSON(PageViewModel)一部分.任何的想法?
function PageViewModel() {
//Properties
this.Name = ko.observable();
this.Title = ko.observable();
this.Language = ko.observable();
//Seo
this.SEOKeywords = ko.observable();
this.SEODescription = ko.observable();
this.SEOIndexPage = ko.observable();
this.SEOGeoPositionLatitude = ko.observable();
this.SEOGeoPositionLongitude = ko.observable();
this.SEOGeoPositionPlaceName = ko.observable();
this.SEOGeoPositionRegion = ko.observable();
}
Run Code Online (Sandbox Code Playgroud)
ko.applyBindings(new PageViewModel());
window.loadFirebugConsole;
console.log(ko.toJSON(PageViewModel));
Run Code Online (Sandbox Code Playgroud)
谢谢米克