我打算在我的大型应用程序中使用AngularJS.所以我正在寻找合适的模块.
是什么区别(角route.js)ngRoute和UI的路由器(角-UI-router.js)模块?
在使用ngRoute的许多文章中,使用$ routeProvider配置路由.但是,当与ui-router一起使用时,路由配置为$ stateProvider和$ urlRouterProvider.
我应该使用哪个模块来提高可管理性和可扩展性?
javascript angularjs angularjs-routing angularjs-module angular-ui-router
我正在开发Web Api,我决定使用自定义DependencyResolver.我引用了[Web API控制器的依赖注入]一文.到目前为止,依赖注入控制器的所有方面都运行良好.我的Owin启动类的配置代码片段
private void RegisterIoC(HttpConfiguration config)
{
_unityContainer = new UnityContainer();
_unityContainer.RegisterType<IAccountService, AccountService>();
.........
.........
config.DependencyResolver = new UnityResolver(_unityContainer);
}
Run Code Online (Sandbox Code Playgroud)
但是当Api第一次启动时,在UnityResolver的 GetService方法中抛出(但被捕获)一些ResolutionFailedException .这是异常消息
"Exception occurred while: while resolving.
Exception is: InvalidOperationException -
The current type, System.Web.Http.Hosting.IHostBufferPolicySelector,
**is an interface and cannot be constructed. Are you missing a type mapping?**"
Run Code Online (Sandbox Code Playgroud)
上述同样的异常抛出以下几种类型
System.Web.Http.Hosting.IHostBufferPolicySelector
System.Web.Http.Tracing.ITraceWriter
System.Web.Http.Metadata.ModelMetadataProvider
System.Web.Http.Tracing.ITraceManager
System.Web.Http.Dispatcher.IHttpControllerSelector
System.Web.Http.Dispatcher.IAssembliesResolver
System.Web.Http.Dispatcher.IHttpControllerTypeResolver
System.Web.Http.Controllers.IHttpActionSelector
System.Web.Http.Controllers.IActionValueBinder
System.Web.Http.Validation.IBodyModelValidator
System.Net.Http.Formatting.IContentNegotiator
Run Code Online (Sandbox Code Playgroud)
我知道抛出这些ResolutionFailedException是因为我没有在上面的类型的单位配置中提供映射.
现在这里是我的问题: -,如果我实现自定义统一DependencyResolver我需要定义上述类型的映射,如果需要定义它们对应的默认实现类型,或者是否有一些替代方法来实现DependencyResolver.我真的担心即使应用程序运行正常,但未能解决上述类型可能会导致严重问题. …
dependency-injection unity-container asp.net-web-api dependency-resolver
请有人知道如何在asp.net Web API 2.1中跟随三个模块一起工作
我所试图做的是开发和Web API,它将会提供恒定的格式JSON数据,意味着如果实际数据
{"Id":1,"UserName":"abc","Email":"abc@xyz.com"}
Run Code Online (Sandbox Code Playgroud)
然后我喜欢把json作为
{__d:{"Id":1,"UserName":"abc","Email":"abc@xyz.com"}, code:200, somekey: "somevalue"}
Run Code Online (Sandbox Code Playgroud)
为此,我尝试使用自定义ActionFilterAttribute但我觉得(仍未确认)在代码遇到异常的情况下,这无法提供类似的格式化数据
请建议我最好的方向.
这是我的自定义属性的简短代码片段.另外建议我是自定义属性是有益的
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true, AllowMultiple = false)]
public class ResponseNormalizationAttribute : ActionFilterAttribute
{
public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
{
base.OnActionExecuted(actionExecutedContext);
var response = actionExecutedContext.Response;
object contentValue;
if (response.TryGetContentValue(out contentValue))
{
var nval = new { data=contentValue, status = 200 };
var newResponse = new HttpResponseMessage { Content = new ObjectContent(nval.GetType(), nval, new JsonMediaTypeFormatter()) };
newResponse.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); …
Run Code Online (Sandbox Code Playgroud) 与Redux连接后,示例https://reacttraining.com/react-router/web/example/auth-workflow中的 PrivateRoute无效.
我的PrivateRoute看起来与原始版本几乎相同,但只连接到Redux并在原始示例中使用它而不是fakeAuth.
const PrivateRoute = ({ component: Component, auth, ...rest }) => (
<Route
{...rest}
render={props =>
auth.isAuthenticated
? <Component {...props} />
: <Redirect to={{ pathname: "/login" }} />}
/>
);
PrivateRoute.propTypes = {
auth: PropTypes.object.isRequired,
component: PropTypes.func.isRequired
}
const mapStateToProps = (state, ownProps) => {
return {
auth: state.auth
}
};
export default connect(mapStateToProps)(PrivateRoute);
Run Code Online (Sandbox Code Playgroud)
用法和结果: -
<PrivateRoute path="/member" component={MemberPage} />
<PrivateRoute path="/member" component={MemberPage} auth={auth} />
<PrivateRoute path="/member" component={MemberPage} …
reactjs redux react-router-redux react-router-v4 react-router-dom
希望您能找到以下用于将查询字符串转换为json对象的函数
var queryStringToJSON = function (url) {
if (url === '')
return '';
var pairs = (url || location.search).slice(1).split('&');
var result = {};
for (var idx in pairs) {
var pair = pairs[idx].split('=');
if (!!pair[0])
result[pair[0].toLowerCase()] = decodeURIComponent(pair[1] || '');
}
return result;
}
Run Code Online (Sandbox Code Playgroud)
用法:
获取当前Windows查询字符串
var result = queryStringToJSON() // without any parameter
Run Code Online (Sandbox Code Playgroud)
从自定义查询字符串中获取json:
var result = queryStringToJSON('?name=prem&age=30&HEIGHT=5.8')
Run Code Online (Sandbox Code Playgroud)
输出: {name:"prem", age:"30", height:"5.8"} //All keys are converted into small letters
要将其转换回url,您可以使用jQuery param方法
$.param(result)
Run Code Online (Sandbox Code Playgroud)
要操纵查询字符串,您可以在JavaScript中简单地使用标准对象操作,并再次使用$ .param方法
result.age=35;
delete result['name'];
Run Code Online (Sandbox Code Playgroud) 我正在使用启用OData的Web Api.我开始工作时提到(只提到问题的相关dll)
Microsoft.AspNet.WebApi.OData
Microsoft.Data.OData
Microsoft.Data.Edm
System.Spatial
Run Code Online (Sandbox Code Playgroud)
但是当我发现OData默认区分大小写时,我寻找一个不区分大小写的解决方案,我已经通过几个帖子支持OData Uri不区分大小写的解析和ODataLib 6.7.0发布然后最终登陆到nuget包Microsoft.OData.核心6.9.0似乎解决了我的问题.在这里我的困惑开始了,它在不同的命名空间下有自己的集合相关库
Microsoft.OData.Core-----------VS------Microsoft.Data.OData
Microsoft.OData.Edm------------VS------Microsoft.Data.Edm
Microsoft.Spatial--------------VS------System.Spatial
Run Code Online (Sandbox Code Playgroud)
上面类似的库之间有什么区别,我们应该相互使用?在矿山的类似案件,Microsoft.OData.Core可以使用的,而不是Microsoft.Data.OData这是解决区分大小写的问题?
简单的问题,但背后有很多意义/讨论!
是否可以让Windows Azure模拟器将浏览器打开到127.0.0.1和端口81以外的URL?
azure azure-storage azure-storage-blobs azure-web-roles azure-table-storage