I want to execute the following code at my C#
page. I know that there are more questions like this here, but I could not find something that could help me. However
You have unbalanced code tags.
<%@ import Newtonsoft.Json.Linq; %>
<%@ import System; %>
<%@using Project.Models;%>
<%@using Project.Controllers;%>
<%
WebIntegrationRestService<int,int> service= new WebIntegrationRestService<int,int>();
service.GetUserByUsername(0,1,User.Identity.Name);
UserType type = null;
if (User.Identity.IsAuthenticated)
{
UserType type = service.GetUserByUsername(0, 1, User.Identity.Name).First().UserType;
}
if (type==UserType.TypeA){%>
<li><%: Html.ActionLink("Add User ", "Create", "User")%></li>
<% } %>
Notice I added an opening code tag between your page-level declarations and the start of your code.
I also added one after the last closing brace.
You should re-think what you're doing though. When you start putting this sort of thing in your views you are asking for trouble (maintenence costs of keeping things in Views, debugging issues, duplicate code, etc).