asp.net-mvc-5

500 error with Twilio C# REST Api on Azure Staging

纵然是瞬间 提交于 2019-12-24 22:25:00
问题 var client = new TwilioRestClient(ConstantKeys.AccountSid,ConstantKeys.AuthToken); // instantiate a new Twilio Rest Client var messageCallBack = client.SendMessage(ConstantKeys.SmsEnabledTwilioNumber, mobileNumber, smsMessage); Above code snippet is working fine on localhost but when we publish and try to use the same on live site we are getting a 500 error.We are using windows azure for hosting our website.It doesn't reach the first line of the above code on production.Can you tell me why ?

MVC 5 - Roles - AuthorizeAttribute outdated

放肆的年华 提交于 2019-12-24 21:25:23
问题 In my previous post i asked how to check/add user roles, but now i face another problem. Since microsoft moved to the new Identity 2.0, AuthorizeAttribute doesn't work anymore. Is there any substitute filter for the Authorize? EDIT: I've made some tests and [Authorize(Users = "SOME_ID")] works, but not [Authorize(Roles = "Admin")]. And i verified if the user was really in that role (Admin) 回答1: Actually [Authorize(Roles = "ROLENAME")] working fine. Check your userRoles (or AspNetUserRoles)

MVC 5 Cannot implicitly convert type 'System.Linq.IQueryable to bool?

╄→尐↘猪︶ㄣ 提交于 2019-12-24 18:05:10
问题 For the life of me I cannot figure how I am getting the error Cannot implicitly convert type 'System.Linq.IQueryable<AnonymousType#1>' to 'bool?' if I double-click the error it takes me to the HomeController and highlights the select statement within the line statsModel.Donations = (from q in db.Shows where (q.Id == 1) select new { q.Donations }); . Show.cs namespace WebApplication1.Models { using System; using System.Collections.Generic; public partial class Show { public int Id { get; set;

How Can I get UserId from ConnectionId in asp.net identity framework SignalR?

雨燕双飞 提交于 2019-12-24 17:43:30
问题 I am using Asp.net Identity framework for authentication. Now I need the User id of connected client from connectionId or role of connected user. 回答1: public class WhateverHub : Hub { public override Task OnConnected() { //Get the username string name = Context.User.Identity.Name; //Get the UserId var claimsIdentity = Context.User.Identity as ClaimsIdentity; if (claimsIdentity != null) { // the principal identity is a claims identity. // now we need to find the NameIdentifier claim var

How to perform HTTP POST and redirect to external site from the POST result?

爱⌒轻易说出口 提交于 2019-12-24 17:24:38
问题 So I can do the following POST submit and get redirected to the payment gateway site @Html.BeginForm(null, null, FormMethod.Post, new { @action = "https://l33tpaymentgateway.com" }) { <input id="RefNo" name="RefNo" type="hidden" value="ABCDE" /> <input id="Amount" name="Amount" type="hidden" value="300" /> <input id="UserEmail" name="UserEmail" type="hidden" value="warheat1990@warheat1990.com" /> <input id="Signature" name="Signature" type="hidden" value="1234567890" /> <input id="ResponseURL

Push Notifications in SignalR from multiple Databases

 ̄綄美尐妖づ 提交于 2019-12-24 16:25:19
问题 I am relatively new to SignalR, What I have done so far are example chat applications on it to get started. We have a project that includes multiple databases, it's a machine data collection app. I have created a web control in ASP.NET MVC to view data of multiple machines at one place. We have multiple users and they can access machines related to their projects. The current solution have a jQuery observer on the mvc page which refreshes the machine controls in a specific time. I am thinking

Receive a complex object from jquery in mvc controller

醉酒当歌 提交于 2019-12-24 15:53:33
问题 I am trying to submit a object from a form to my mvc controller. here is the js: <script> function submitForm() { var usersRoles = new Array; jQuery("#dualSelectRoles2 option").each(function () { usersRoles.push(jQuery(this).val()); }); var model = new Object(); model.user = jQuery('#selectUser').val(); model.roleslist = usersRoles; console.log('model: ' + 'user: ' + model.user + 'roles: ' + model.roleslist); console.log('JSON: ' + JSON.stringify(model)); jQuery.ajax({ type: "POST", url: "

In ASP.NET MVC5, how can I hide the Action name when an a tag is generated in Razor using Url.Action?

倖福魔咒の 提交于 2019-12-24 15:19:07
问题 As the title says. I have a route set up and working fine, which provides a default action when none is specified. I just want to hide the action from the URL because it's unnecessary clutter. Setting the "ActionName" parameter as null , or "" , will just result in the current page's action being substituted instead - which doesn't work. I'm open to using @Html.ActionLink() if that will get me what I need. My route definition is routes.MapRoute( name: "MyBookRoute", url: "Book/{id}", defaults

Is there a simple way to implement Single Sign On across domains in MVC5 [duplicate]

你。 提交于 2019-12-24 15:18:33
问题 This question already has answers here : ASP.NET Identity Cookie across subdomains (4 answers) Closed 4 years ago . Scenario: Two separate web projects, running om these domains: account.ilovepandas.com ilovepandas.com Using ASP.Net Identity, is there a simple way in MVC5 to implement a shared login, so that if the user is logged in to ilovepandas.com and goes to account.ilovepandas.com, he will already be authenticated? I have done research on the topic, and there are some quite complicated

MVC Ninject: How to add NinJect bindings from an MVC Area project

送分小仙女□ 提交于 2019-12-24 14:06:19
问题 I've been using this blog example: http://blog.longle.net/2012/03/29/building-a-composite-mvc3-application-with-pluggable-areas/ I have the concepts working in my solution. However, I'm trying to figure out a good way only add bindings to the kernel if a user has permissions to access a module/area. I've read up some on the ServiceLocator but I was trying to stay away from it. One thing I'm trying just to get things to work is user Contructor injection in the default constructor for a module.