why my dropzone doesn't work properly - c#

i used this tutorial for create dropzone area in my web application mvc 5.
http://www.codeproject.com/Articles/874215/File-upload-in-ASP-NET-MVC-using-Dropzone-JS-and-H
but when i drag and drop my image, the dropzone layout doesn't work.
below is my code:
_layout
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>#ViewBag.Title - My ASP.NET Application</title>
#Styles.Render("~/Content/css")
#Styles.Render("~/Content/dropzonescss")
#Scripts.Render("~/bundles/modernizr")
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
#Html.ActionLink("Application name", "Index", "Home", null, new { #class = "navbar-brand" })
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>#Html.ActionLink("Home", "Index", "Home")</li>
<li>#Html.ActionLink("About", "About", "Home")</li>
<li>#Html.ActionLink("Contact", "Contact", "Home")</li>
</ul>
</div>
</div>
</div>
<div class="container body-content">
#RenderBody()
<hr />
<footer>
<p>© #DateTime.Now.Year - My ASP.NET Application</p>
</footer>
</div>
#Scripts.Render("~/bundles/jquery")
#Scripts.Render("~/bundles/bootstrap")
#Scripts.Render("~/bundles/dropzonescripts")
<script type="text/javascript">
Dropzone.options.dropzoneJsForm = {
//prevents Dropzone from uploading dropped files immediately
autoProcessQueue: false,
init: function () {
var submitButton = document.querySelector("#submit-all");
var myDropzone = this; //closure
submitButton.addEventListener("click", function () {
//tell Dropzone to process all queued files
myDropzone.processQueue();
});
}
};
</script>
#RenderSection("scripts", required: false)
</body>
</html>
Index
#{
ViewBag.Title = "Home Page";
}
<form action="~/Home/SaveUploadedFile" method="post" class="dropzone" id="Dropzone.options.dropzoneJsForm" >
<div class="fallback">
<input name="file" type="file" multiple />
<input type="submit" value="Upload" />
</div>
</form>
homecontroller
public ActionResult SaveUploadedFile()
{
bool isSavedSuccessfully = true;
string fName = "";
try
{
foreach (string fileName in Request.Files)
{
HttpPostedFileBase file = Request.Files[fileName];
//Save file content goes here
fName = file.FileName;
if (file != null && file.ContentLength > 0)
{
var originalDirectory = new DirectoryInfo(string.Format("{0}Images\\WallImages", Server.MapPath(#"\")));
string pathString = System.IO.Path.Combine(originalDirectory.ToString(), "imagepath");
var fileName1 = Path.GetFileName(file.FileName);
bool isExists = System.IO.Directory.Exists(pathString);
if (!isExists)
System.IO.Directory.CreateDirectory(pathString);
var path = string.Format("{0}\\{1}", pathString, file.FileName);
file.SaveAs(path);
}
}
}
catch (Exception ex)
{
isSavedSuccessfully = false;
}
if (isSavedSuccessfully)
{
return Json(new { Message = fName });
}
else
{
return Json(new { Message = "Error in saving file" });
}
}
BundleConfig add
bundles.Add(new StyleBundle("~/Content/dropzonescss").Include(
"~/Scripts/dropzone/css/basic.css",
"~/Scripts/dropzone/css/dropzone.css"));
bundles.Add(new ScriptBundle("~/bundles/dropzonescripts").Include(
"~/Scripts/dropzone/dropzone.js"));
I have no idea why it behaves this way.
The loading part is working properly, but the graphics is wrong and looks like:

It looks like the dropzone nuget package doesn't create the \css sub folder for the dropzone css files, so the bundle config is incorrect. (well it is correct but the folder isn't there).
Create the folder scripts\dropzone\css (and move the css files from the scripts\dropzone folder to that new folder)
You can see how the dropzone folder should look by looking at the solution that is on github:
Dropzone example solution

Related

I need help. My ASP.Net MVC Logout not working

When I log in, I am unable to log out. The session doesn't clear and I don't know why? When I click on Logout, it doesn't do anything. I want to click Logout and then it switches the navbar to show Register/Login. But it doesn't clear the session. In the Logout Method in UserController.cs, I've tried Session.Clear() Session.Abandon() FormsAuthentication.Signout() Below is my Controller
UserController.cs
// Login POST
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Login(UserLogin login, string ReturnUrl = "")
{
string message = "";
using (SocialEntities dc = new SocialEntities())
{
var v = dc.tblUsers.Where(a => a.Email ==
login.Email).FirstOrDefault();
if (v != null)
{
if (string.Compare(HashPassword.Hash(login.Password),
v.Password) == 0)
{
int timeout = login.RememberMe ? 525600 : 20; // 525600
min = 1 year
var ticket = new FormsAuthenticationTicket(login.Email,
login.RememberMe, timeout);
string encrypted = FormsAuthentication.Encrypt(ticket);
var cookie = new
HttpCookie(FormsAuthentication.FormsCookieName, encrypted);
cookie.Expires = DateTime.Now.AddMinutes(timeout);
cookie.HttpOnly = true;
Response.Cookies.Add(cookie);
if (Url.IsLocalUrl(ReturnUrl))
{
return Redirect(ReturnUrl);
}
else
{
Session["Email"] = login.Email;
return RedirectToAction("Index", "Home");
}
}
}
else
{
message = "Error";
}
}
ViewBag.Message = message;
return View();
}
// Logout
[Authorize]
[HttpPost]
public ActionResult Logout()
{
Session.Clear();
return RedirectToAction("Index", "Home");
}
And here is my _Layout.schtml
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>#ViewBag.Title - Social Network</title>
#Styles.Render("~/Content/css")
#Scripts.Render("~/bundles/modernizr")
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-
target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
#Html.ActionLink("Social Network", "Index", "Home", new { area = "" }, new { #class =
"navbar-brand" })
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>#Html.ActionLink("Home", "Index", "Home")</li>
<li>#Html.ActionLink("About", "About", "Home")</li>
<li>#Html.ActionLink("Contact", "Contact", "Home")</li>
</ul>
#*#Html.Partial("_loginPartial")*#
<ul class="nav navbar-nav" style="float:right !important">
#if (Session["Email"] != null)
{
<li> <p style="color:red; margin-top:15px;">Hello, #Session["Email"] </p></li>
<li>#Html.ActionLink("Logout", "Index", "Home")</li>
}
else
{
<li>#Html.ActionLink("Register", "Registration", "User")</li>
<li>#Html.ActionLink("Login", "Login", "User")</li>
}
</ul>
</div>
</div>
</div>
<div class="container body-content">
#RenderBody()
<hr />
<footer>
<p>© #DateTime.Now.Year - Keane, Inc.</p>
</footer>
</div>
#Scripts.Render("~/bundles/jquery")
#Scripts.Render("~/bundles/bootstrap")
#RenderSection("scripts", required: false)
</body>
</html>

Avatar display visual studio changes query

I've been programming a forum for funsies that I'll eventually be creating into a sharepoint add-in. I'm currently unable to solve an issue with the _Layout.cshtml page as in Visual Studio 2010 the page is laid out differently than it is in 2013. No problem right, I still get my page aware that there is an avatar on the nav bar however in 2013 it refuses to show then picture. Code and screenshot links provided below.
Visual Studio 2013(broken):
_Layout.cshtml 2013:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>#ViewBag.Title - Forum</title>
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<meta name="viewport" content="width=device-width" />
#Styles.Render("~/Content/css")
#Scripts.Render("~/bundles/modernizr")
</head>
<body>
<header>
<div class="content-wrapper">
<div class="float-left">
<p class="site-title"> <img src="#" /></p>
</div>
<div class="float-right">
<section id="login">
#Html.Partial("_LoginPartial")
</section>
<nav>
<ul id="menu">
<li>#Html.ActionLink("Home", "Index", "Home")</li>
<li>#Html.ActionLink("Forums", "Index", "Forum")</li>
<li>#Html.ActionLink("About", "About", "Home")</li>
<li>#Html.ActionLink("Contact", "Contact", "Home")</li>
<li>#Html.ActionLink("Avatar", "SelectAvatar", "Avatar")</li>
#Html.Action("Avatar", "Layout")
</ul>
</nav>
</div>
</div>
</header>
<div id="body">
#RenderSection("featured", required: false)
<section class="content-wrapper main-content clear-fix">
#RenderBody()
</section>
</div>
<footer>
<div class="content-wrapper">
<div class="float-left">
<p>© #DateTime.Now.Year - ID</p>
</div>
</div>
</footer>
#Scripts.Render("~/bundles/jquery")
#Scripts.Render("~/bundles/jqueryval")
#RenderSection("scripts", required: false)
</body>
</html>
LayoutController.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LbForum.Models;
namespace LbForum.Controllers
{
public class LayoutController : Controller
{
private IStateRepository stateRepository = null;
public LayoutController()
: this(new SessionStateRepository())
{
}
public LayoutController(IStateRepository sessionStateRepository)
{
this.stateRepository = sessionStateRepository;
}
//
// GET: /Layout/
public ContentResult Avatar()
{
string imgPath = "~/Images/Avatars";
ForumUserState forumUserState = stateRepository.GetForumUserState();
if (forumUserState.AvatarFileName != string.Empty)
{
imgPath += forumUserState.AvatarFileName;
}
else
{
imgPath += "avatar1.jpg";
}
string imgTag = string.Format("<img src='{0}' alt='User Avatar' width='40' height='40'/>", imgPath);
return new ContentResult() { Content = imgTag };
}
}
}
Visual Studio 2010(fixed):
_Layout.cshtml 2010:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>#ViewBag.Title - Forum</title>
#Styles.Render("~/Content/css")
#Scripts.Render("~/bundles/modernizr")
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"><</span>
<span class="icon-bar"></span>
</button>
#Html.Raw(#Html.ActionLink("[replacetext]", "Index", "Home",
new { area = "" },
new { #class = "navbar-brand" })
.ToHtmlString().Replace("[replacetext]",
"<img src=\"/images/forum.jpg\" alt=\"QA Forum logo\" />"))
</div>
<div class="navbar-collapse collapse ">
<ul class="nav navbar-nav">
<li>#Html.ActionLink("Home", "Index", "Home")</li>
<li>#Html.ActionLink("Forums", "Index", "Forum")</li>
<li>#Html.ActionLink("Threads", "Index", "Thread")</li>
<li>#Html.ActionLink("Posts", "Index", "Post")</li>
<li>#Html.ActionLink("About", "About", "Home")</li>
<li>#Html.ActionLink("Contact", "Contact", "Home")</li>
<li>#Html.ActionLink("Avatar", "SelectAvatar", "Avatar")</li>
<li>#Html.ActionLink("Admin", "Index", "Admin")</li>
#Html.Action("Avatar", "Layout")
</ul>
#Html.Partial("_LoginPartial")
</div>
</div>
</div>
<div class="container body-content">
#RenderBody()
<hr />
<footer>
<p>© #DateTime.Now.Year - ID</p>
</footer>
</div>
#Scripts.Render("~/bundles/jquery")
#Scripts.Render("~/bundles/jqueryval")
#Scripts.Render("~/bundles/bootstrap")
#RenderSection("scripts", required: false)
</body>
</html>
Now that we have the meat'n'potatoes...
Your 2010 example (which is working) is simply referencing /images/forum.jpg (which appears to exist as an asset on your site). So all is fine there.
The 2012 version is appears you tried to refactor into a ChildAction. By doing so you've also switched how the resource is located, referencing ~/Images/avatars instead of just /Images/avatars (note the tilde).
For the simplest "check if it works" path (and assuming your /images/forum.jpg file still exists) try just outputting a hard-coded value in your child action first:
public ContentResult Avatar()
{
string imgPath = "/images/forums.jpg"; // Hard-coded
string imgTag = string.Format("<img src='{0}' alt='User Avatar' width='40' height='40'/>", imgPath);
return new ContentResult() { Content = imgTag };
}
If that works, it has to do with the way you assemble the path. Remember locations to clients should be relative your website, so ~/ means nothing to them.
Some general guidance:
Decorate this action with [ChildActionOnly] to avoid being called directly.
Use a view and pass it the url as the model to avoid mixing logic/presentation.
Consider moving this code, altogether, into an HtmlHelper and avoid the round-trip to another controller.
Taking bullet points 1 & 2 and applying them:
LayoutController.cs:
public class LayoutController : Controller
{
/* snip */
// Hard-coded values should be const
const String AvatarDefaultImage = "avatar1.jpg";
[ChildActionOnly]
public PartialViewResult Avatar()
{
var forumUserState = stateRepository.GetForumUserState();
if (!String.IsNullOrEmpty(forumUserState.AvatarFileName))
{
// Pass off the URL as the model
return PartialView(model: forumUserState.AvatarFileName);
}
// default fallback
return PartialView(model: AvatarDefaultImage);
}
}
~/Views/Layout/Avatar.cshtml:
#model String
<img src="/Images/Avatars/#Model" alt="User Avatar" width="40" height="40"/>

How to call a search method in a _Layout.cshtml?

I'm trying to create a search method, that is called in my _Layout.cshtml and when I click on submit button, the user is redirected to "search view".
I' following this tutorial, but the author call your method at index view and I need to call the method at _Layout to be redirect to another view that will give me the return of method.
This is my _Layout, is basic a nav-bar from bootstrap with a textfield and a button, that the user can put what he need to find:
#model IEnumerable<TestTcc2.Models.Musica>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>#ViewBag.Title</title>
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<meta name="viewport" content="width=device-width" />
#Styles.Render("~/Content/Bootstrap")
#Scripts.Render("~/bundles/modernizr")
#Scripts.Render("~/bundles/jquery")
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">#Html.ActionLink("your logo here", "IndexOuvinte", "Home")</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li>#Html.ActionLink("Home", "IndexOuvinte", "Home")</li>
</ul>
<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
<ul class="nav navbar-nav navbar-right">
<li>#Html.ActionLink("Manage Account", "Manage", "Account")</li>
<li>#using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm" }))
{
#Html.AntiForgeryToken()
Log off}</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</div>
<div class="container">
#RenderSection("featured", required: false)
#RenderBody()
</div>
<!--Fim container -->
</body>
</html>
and this is the method that I want to call at _Layout.cshtml:
public ActionResult Search(string search)
{
var musicas = from m in db.Musicas select m;
if (!String.IsNullOrEmpty(search))
{
musicas = musicas.Where(s => s.Nome.Contains(search));
return RedirectToAction("Search"); //name of view that will return the data
}
return View(musicas);
}
Well, you might consider specifying an action to the form or just use the appropriate helper to generate it:
#using (Html.BeginForm("Search", "SomeController", null, FormMethod.Post, new { #class = "navbar-form navbar-left", role = "search" }))
{
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default">Submit</button>
}

When submitting form not calling controller function

When clicking the submit button the auth function isn't being called, I haven't been able to figure out why.
html for the template for all pages:
<!DOCTYPE html>
<html ng-app ="myApp">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MyApp #ViewBag.Title</title>
<link href="~/Content/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="~/Content/Site.css" rel="stylesheet" type="text/css" />
<script src="~/Scripts/modernizr-2.6.2.js"></script>
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="~/Scripts/bootstrap.min.js"></script>
<script src="~/Scripts/angular.min.js"></script>
<script src="~/js/Login.js"></script>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
#Html.ActionLink("myApp", "Index", "Home", null, new { #class = "navbar-brand" })
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
</ul>
</div>
</div>
</div>
<div class="container body-content">
#RenderBody()
<hr />
<footer>
<p>© #DateTime.Now.Year - myApp</p>
</footer>
</div>
</body>
</html>
html for this pages view:
#{
ViewBag.Title = "Login";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2></h2>
<div id="loginBox">
<auth-modal></auth-modal>
</div>
here is the html for the custom directive:
<div class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title"></h4>
</div>
<div class="modal-body">
<form class="form-signin" name="authForm" ng-submit="auth()" ng-controller ="AuthController" novalidate>
<input type="text" class="form-control" placeholder="user name" ng-model ="AuthController.user.username" required autofocus>
<input type="password" class="form-control" placeholder="password" ng-model ="AuthController.user.password" required>
<input type="submit" class="btn btn-primary" value="Submit" />
</form>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
Here is the JS:
(function () {
var MyApp = angular.module('MyApp', []);
MyApp.controller('AuthModalController', function () {
MyApp.user = {};
console.log("AuthModalController ran");
$(".modal").modal({});
});
MyApp.directive("authModal", function () {
return { restrict: 'E', templateUrl: '\\js\\templates\\auth-modal.html', controller: 'AuthModalController',controllerAs: 'authmodalCtrl'}
});
MyApp.controller('AuthController',function () {
this.user = {};
console.log("AuthController ran");
this.auth = function () {
console.log("user " + this.user);
};
});
})();
MVC 5 Controller:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MyApp.Controllers
{
public class MyAppController : Controller
{
//
// GET: /MyApp/
public ActionResult Index()
{
return View();
}
}
}
Edit: I'm adding on here that I couldn't get the code linked below to run except by adding the ng-app="app-name-from-module" directive alongside the controller declaration on the form object, which is not in the linked angular-js documentation!
Reading just the documentation I noticed quite a few issues,
1) You're declaring "myApp" and using "MyApp" unless thats an obfuscation error.
2) I think your controller is missing a few things per the documentation (esp $scope variable, https://docs.angularjs.org/guide/controller)
2a) You're not attaching the auth function to the $scope
3) The .controller seems to take a string and an array as an argument, not a generic function.
Per: https://docs.angularjs.org/api/ng/directive/ngSubmit
<script>
angular.module('submitExample', [])
.controller('ExampleController', ['$scope', function($scope) {
$scope.list = [];
$scope.text = 'hello';
$scope.submit = function() {
if ($scope.text) {
$scope.list.push(this.text);
$scope.text = '';
}
};
}]);
</script>
<form ng-app="submitExample" ng-submit="submit()" ng-controller="ExampleController">
Enter text and hit enter:
<input type="text" ng-model="text" name="text" />
<input type="submit" id="submit" value="Submit" />
<pre>list={{list}}</pre>
</form>

MVC: An unhandled exception of type 'System.StackOverflowException' occurred in System.Core.dll

This is my main layout of the application
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>#ViewBag.Title - My ASP.NET Application</title>
#Styles.Render("~/Content/css")
#Scripts.Render("~/bundles/modernizr")
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top bs-docs-nav" role="banner">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
#Html.ActionLink("Date Picker", "Index", "Home", null, new { #class = "navbar-brand" })
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>#Html.ActionLink("Home", "Index", "Home")</li>
<li>#Html.ActionLink("About", "About", "Home")</li>
<li>#Html.ActionLink("Contact", "Contact", "Home")</li>
</ul>
#Html.Partial("_LoginPartial")
</div>
</div>
</div>
#if (User.Identity.IsAuthenticated)
{
<div class="row">
<div class="col-md-3">
<div class="bs-sidebar hidden-print affix" role="complementary">
<ul class="nav bs-sidenav">
<li class="active">
#Html.ActionLink("Address Book","Index","AddressBook")
<ul class="nav">
<li>
#Html.ActionLink("Add Contact", "AddPerson", "AddressBook")
</li>
</ul>
</li>
<li>
#Html.ActionLink("App", "Create", "Appointment")
</li>
<li>
#Html.ActionLink("myconn", "Index", "Connection")//error when I click this link.
</li>
</ul>
</div>
</div>
</div>
}
<div class="container body-content">
#RenderBody()
<hr />
<footer>
<p>© #DateTime.Now.Year - MyApp</p>
</footer>
</div>
#Scripts.Render("~/bundles/jquery")
#Scripts.Render("~/bundles/bootstrap")
#RenderSection("scripts", required: false)
</body>
</html>
I get the sidebar when the user is logged in, all the links work in sidebar except
#Html.ActionLink("myconn", "Action", "Controller")
When I click the link called SuperOffice browser link changes to http://localhost:14834/Connection
but I get error: in visual studio saying
An unhandled exception of type 'System.StackOverflowException' occurred in System.Core.dll
Here is my controller code
[Authorize]
public class Controller : Controller
{
private readonly IConnectionRepository _connectionRepository;
public ConnectionController(IConnectionRepository connectionRepository)
{
_connectionRepository = connectionRepository;
}
}
When I put breakpoint in Index method of Connection controller, and click the SuperOffice link, I don't even get to that method.
Any idea what is happening?
I find it strange that all the link are working and I get forwarded to controller and all thing works perfect except that one.
You probably have [Authorize] attribute somewhere that is giving you stackoverflow.
var hasSuperOfficeConnection = _connectionRepository.CheckIfSuperOfficeIsConnected(userId);
var model = new Index
{
IsSuperOfficeConnected = hasSuperOfficeConnection
};
I think there is a infinite loop here If you can give more code (ie IsSuperOficeConnected) we can help you more
public class ConnectionRepository:IConnectionRepository
{
private readonly DatePickerDbContext _db;
//private readonly ISuperOfficeRepository _superOfficeRepository;
public ConnectionRepository(DatePickerDbContext db)//, ISuperOfficeRepository superOfficeRepository
{
_db = db;
// _superOfficeRepository = superOfficeRepository;
}
public int GetConnectionId(string connectionName)
{
var connection = _db.Connections.Single(c => c.Name == connectionName);
return connection.Id;
}
public bool CheckIfSuperOfficeIsConnected(string userId)
{
var connectionId = GetConnectionId("SuperOffice");
var result = _db.UserConnections.Where(uc => uc.UserId == userId && uc.ConnectionId == connectionId);
return result.Any();
}
}

Categories