There is class Task.cs

public class Task
{
    [Required]
    public int Id { get; set; }

    [Required]
    public string Title { get; set; }

    public string Description { get; set; }

    public int Priority { get; set; }

    [Required]
    public string DateCreation { get; set; }

    public string DateTarget { get; set; }

    public bool IsActive { get; set; }

    public bool IsDeleted { get; set; }

}

and its property Priority can have 4 different values: 0 - low, 1 - normal, 2 - high, 3 - extreme. What is the best way to keep these values? Should I create class Priority, or just create table Priority in my database and set these values in or use List maybe?
It's my first attempt to create Asp.Net MVC application so I'm not sure what way is better.

I have ASP site with simple WCF service that I can run from Visual Studio for debugging purposes. Site starts and runs on IIS Express on specific port and I can see metadata in browser by entering http://localhost:35168/mySrv.svc. I stop VS , but this page is still available and refresh has no influence on that. Looks my service is running? Why? How to stop it?

I am using VS 2015. I am creating a a web form application. I've 4 Master Pages for different user roles. Everything was working fine. But when i move master pages to new folder then i got error of page not found then i edit my .csproj file in notepad and set the correct path for every master page file. Then project run successfully. But after login I got that error. **

dashboard.aspx is not allowed here because it does not extend class 'System.Web.UI.MasterPage'.

Here is my solution explorer snap shot. enter image description here

Before moving files the files that are in CTO folder were in the root directory. When i move them to different folder then issue comes. And here is the snap shot of my .csproj file that i edit. enter image description here

And here is my snap shot of error page: enter image description here

In that picture Inherits="E_Challan.CTO.CTOAdmin" represents that E_Challan is my project. CTO is folder and CTOAdmin is my master page which is located in CTO folder. So where i am doing mistake?

I have a basic form allowing users to input details which then gets posted and saved to a database - this works as expected without any issues:

@model R32.Register.Models.RegisterCar
@{
    ViewBag.Title = "Edit Your R32";
}

<h2>Edit R32</h2>
<div>
    @using (Html.BeginForm("UpdateCar", "Garage", FormMethod.Post))
    {
        @Html.ValidationSummary(true)
        <fieldset>
            <legend>Enter details</legend>
            <ol>                   
                <li>
                    @Html.LabelFor(m => m.NumberPlate)
                    @Html.EditorFor(m => m.NumberPlate, new { @class = "form-control" })
                    @Html.ValidationMessageFor(m => m.NumberPlate)
                </li>                    
                <li>
                    @Html.LabelFor(m => m.Edition)
                    @Html.EnumDropDownListFor(m => m.Edition, "Select an edition:", new { @class = "form-control" })
                    @Html.ValidationMessageFor(m => m.Edition)
                </li>
                <li>
                    @Html.LabelFor(m => m.Colour)
                    @Html.EnumDropDownListFor(m => m.Colour, "Select a colour:", new { @class = "form-control" })
                    @Html.ValidationMessageFor(m => m.Colour)
                </li>                    
            </ol>
            <input type="submit" value="Save Changes" />
        </fieldset>
    }
</div>

Model snippet:

[Required]
[Display(Name="Edition")]
public MkEnum? Edition { get; set; }

Enum:

public enum MkEnum
{
    [Display(Name="Mk4")]
    Mk4 = 1,
    [Display(Name="Mk5")]
    Mk5 = 2
}

The control renders as expected, with the Edition dropdownlist having three values: "Select an edition", "Mk4", and "Mk5".

The user is able to select an edition, control is validated, then posted to the controller.

The Post is successful, and all selected values are sent to the controller - the app then persists the data in a database, and so on, without any problems.

The issue is when I pass this model back into the same View to allow the user to edit the saved data, the saved values for the enums are NOT being set as the selected value in the dropdownlist.

I can confirm that any saved string values, such as NumberPlate in this example, are being passed back into the view and loaded into the UI.

Putting a breakpoint on the viewmodel as it renders I can confirm that my @model contains the saved values for enum properties - Edition for example - but the end result is that the "Select an edition:" dropdown list is rendered containing the expected dropdown values, but it's value is the default "Select an edition:" instead of the actual value passed in via. m.Edition.

I have been able to get this working using DropDownListFor - but am having difficulties in understanding why this is not working using EnumDropDownListFor, as this clearly seems like a more elegant solution.

Does anyone have any help/advice for this?

I am trying to use the jquery date picker for a simple date picker field in asp.net webforms all the examples appear to be for mvc these days so why i am asking the question.

If I am using the jquery date picker above how do i set the null date so my entity does not through an exception if was using telerik controls I would normally set it to null like this.

 <asp:TextBox ID="dateOfBirth" data-provide="datepicker"   data-date-format='dd/mm/yyyy'  CssClass="form-control" runat="server"></asp:TextBox><span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>

But I cant use the rad controls for this client.

rdpDatePassportIssued.Value == DateTime.MinValue ? new DateTime(1900, 1, 1) : rdpDatePassportIssued.Value;

I have an ASP.NET form with Telerik Ajax RadMenu control hosted in a "portlet" inside a Plumtree portal. The control works on first load, but then stops after postback occurs. The postback occurs as a result of submit by another control on the same form. So this seems Ajax related. The trouble is the RadMenu stops working.

How to troubleshoot the issue, and learn WHY this is happening? The second goal being how to resolve, but first things first.

The tools I am familiar with are the IE debugger, and Fiddler 4 (from Telerik).

What tools should I bring into this course? What links to how-to use these tools?

The environment:

Windows 7 64 with IIS

Oracle WebCenterInteraction ver 10.3.3 (Plumtree)

Thank you.

I'm creating a string in my code-behind, part of which contains a hyperlink. I have created my URl like so:

Uri dispURI = new Uri("/thispage.aspx");

How do I display the hyperlink in the following manner:

Pseudo-code

String dispStr = "lorem ipsum " + dispURI.textToDisplay("custom text" + " dolor";

So that the resulting page looks like this:

Lorem ipsum custom text dolor

I need to remove CSS hover functionality using JavaScript.

I have a button on a form which submits data to our db server. Using OnClientClick() of an ASP.NET Button control I would like to change the element's text to 'Submitting..' using getElementById(), change the background color of the button to Light Grey and more importantly disable the following .button:hover effect I have in my CSS.

.button:hover, 
.content-form input.button:hover, 
#comment-form #submit:hover   
{
    background-color: #333;
}

All I am really interested in is the Javascript to remove/disable the above CSS

e.g. OnClientClick="getElementByID('ButtonName').blahblahblah;"

I developed an intranet based application with asp.net mvc 4. I build/published the file using file system publish method then moved the published file to the server (Server 2012) which runs on sql server 2012. As usual, I enabled Windows authentication, enabled directory browsing and created a separate appPool for the application using the integrated pipeline and local system as identity. I then liked the application to it's appPool. On browsing the application, it is viewing as though the css file is missing.

The below is my supposed homepage. enter image description here

Below is my html view referecing the css and js files when viewd from my application:

<!-- core CSS -->
<link href="/Content/css/bootstrap.min.css" rel="stylesheet"/>
<link href="/Content/css/font-awesome.css" rel="stylesheet"/>
<link href="/Content/css/animate.min.css" rel="stylesheet"/>
<link href="/Content/css/prettyPhoto.css" rel="stylesheet"/>
<link href="/Content/css/main.css" rel="stylesheet"/>
<link href="/Content/css/jquery.fancybox-1.3.4.pack.css" rel="stylesheet"/>
<link href="/Content/css/responsive.css" rel="stylesheet"/>

<!-- core JS -->
<script src="/Scripts/modernizr-2.6.2.js"></script>

<script src="/Scripts/jquery-1.10.2.js"></script>
<script src="/Scripts/jquery-migrate-1.2.1.js"></script>
<script src="/Scripts/jquery.unobtrusive-ajax.js"></script>
<script src="/Scripts/main.js"></script>
<script src="/Scripts/jquery.prettyPhoto.js"></script>
<script src="/Scripts/jquery.isotope.min.js"></script>
<script src="/Scripts/html5shiv.js"></script>
<script src="/Scripts/jquery.fancybox-1.3.4.pack.js"></script>
<script src="/Scripts/wow.min.js"></script>
<script src="/Scripts/jquery.validate.js"></script>
<script src="/Scripts/jquery.validate.unobtrusive.js"></script>
<script src="/Scripts/bootstrap.js"></script>
<script src="/Scripts/respond.js"></script>
<script src="//tinymce.cachefly.net/4.2/tinymce.min.js"></script>

And below is the html view of the application after publishing. The CSS file seem not to be referenced. The js files too seem not to be referenced.

<!-- core CSS -->
<link href="/TBC2015Live/Content/css?v=9rtONLVCUCbRdiqwPX0SXmvkuPX-D8w3c-hnpsaUERI1" rel="stylesheet"/>


<!-- core JS -->
<script src="/TBC2015Live/bundles/modernizr?v=wBEWDufH_8Md-Pbioxomt90vm6tJN2Pyy9u9zHtWsPo1"></script>
<script src="/TBC2015Live/bundles/jquery?v=DuNp63axKEm__mWBxQ-SlhlM2syuEL8qBaUB-hzYBAc1"></script>
<script src="/TBC2015Live/bundles/jqueryval?v=NOVQDySGO89wzMzO5x7mWS4C_uAdynpZe_Lk2y-xEM41"></script>
<script src="/TBC2015Live/bundles/bootstrap?v=2Fz3B0iizV2NnnamQFrx-NbYJNTFeBJ2GM05SilbtQU1"></script>

Can anybody help me out?

I have 500.19 - Internal Server Error on production server.

On the page I am trying to access I have a htmleditorextender from the ajaxcontroltoolkit. In order to make the htmleditorextender work on the development server I had to add the following entry to the web.config file:

<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
  <add name="AjaxFileUploadHandler" verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit" />
</handlers>
<security>
  <requestFiltering>
    <requestLimits maxAllowedContentLength="4294967295"/>
  </requestFiltering>
</security>
</system.webServer>

it all worked fine until I uploaded it to the production server (if it helps at all it is held in a 1 and 1 server.) The error occurs at the following line:

      <requestFiltering>
    <requestLimits maxAllowedContentLength="4294967295"/>
  </requestFiltering>

I cant remove the line because I need it for the htmleditorextender to work. Any suggestions would be greatly appreciated.

config error:

This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false". 

This question is an exact duplicate of:

protected void Page_Load(object sender, EventArgs e)
{
    TextBox1.Text = Request.Form["tbContractNo"];  
    TextBox2.Text = (TextBox1.Text).Length.ToString();
}
    protected void Button1_Click(object sender, EventArgs e)
{        
    string result = "";
    result = (TextBox1.Text).Substring(4, 1);

try
    {

    }
    catch
    {
    }
    finally
    {

        if (result == "H")
        {
            HiddenField2.Value = TextBox1.Text ; 
            Server.Transfer("~/LtssEnrollment-HCS.aspx", true);
        }
        else
        {
            if (result == "I")
            {
                Server.Transfer("~/LtssEnrollment-ICF.aspx", true);
            }
        }
    }
}

Textbox1 shows "0000H07C7". Textbox2 show 9 - the number of digits. Get startIndex cannot be larger than length of string.

  Parameter name: startIndex

 Source Error: 


Line 43:         //string alpha2 = alpha.ToString();
Line 44:         string result = "";  
Line 45:         result = (TextBox1.Text).Substring(4, 1);  
Line 46: 
Line 47:     try

Stack Trace: 

What is going on? Is the value of TextBox1 losing its value on button click??

I have a SQL Server database with 2 tables:

t1 - Category

Id
Name

t2- Product

Id
Name
CategoryId

I want to delete a row from the Category table, but since I have the foreign key I need to handle the products that has the CategoryId I want to delete.

So I did this:

var ProdCatID = (from prod in DataContext.Products
                 where prod.CategoryId == Convert.ToInt32(Id)
                 select prod).First();

ProdCatID.CategoryId = null;
DataContext.SubmitChanges();

var DelCat = (from cat in DataContext.Categories
             where cat.Id == Convert.ToInt32(Id)
             select cat).ToList();

DataContext.Categories.DeleteAllOnSubmit(DelCat);
DataContext.SubmitChanges();

What Im trying to do is to check if there is any product with thatCategoryId, if there is - I want to set theCategoryIDto null and then delete the row from theCategory` table.

It is working when I have a product with a CategoryId but when I can't delete it.

Any ideas?

I have a ASP.Net Web Forms application that calls a WCF service hosted on IIS via a button click event inside a Ajax Update panel. When I click the button I call a WCF Async process that can take over 1 minute to return. I've noticed when the task is running and I open another tab in my browser the web page freezes/clocks until the long running task returns. I assume that the first task is locking the UI thread causing anyone else to use the web page to have to wait.

How can I run a task, update the UI with the results and not block the UI for other Tabs/Users?

Here is a snipit of code:

 protected void btnsearch_ServerClick(object sender, EventArgs e)
    {

        Page.RegisterAsyncTask(new PageAsyncTask(async () =>
        {
            DataSet ds;
            ds = await data.GetReportAsync();

            grdsummary.DataSource = ds.Tables[0];
            grdsummary.DataBind();
        }));

    }

I did try adding .ConfigureAwait(false) to the Async call but that didn't do anything.

Long story short: We're trying to set up Durandal SPA in our pre-existing ASP.NET MVC website. What's we're going for is the ability to hide the SPA behind a feature flag, to where we can enable the SPA flag and have our website adjust accordingly.

We have that portion of it working. However, what we had to do is prefix all of our routes with "/app#" and then tack on the controller/action. For example, "Index" would become "app#Index" in the URL. Durandal routing works just fine with this approach - it pulls the necessary views into place.

What we would like is to use the same routes instead of prefixing each one with "app#" - essentially use Durandal routing when the SPA flag is enabled, otherwise use normal MVC routing, but keep the routes the same.

Any suggestions?

I have one project which is Developed in Web Forms 1.0 Framework know I migrate that product to 2010. Project is running well no errors. The issue i am facing is when i run the project it show me the error that the username and password is not correct when i use to login in Home page,The database is no other server

But when running same code by IIS server getting

Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'

I have an ASP.NET Web API application which has two types of users — clients and drivers. Currently, I have methods in the client and driver controller for registering clients and drivers. I realised the correct way to do this is through the built-in authentication system via the ApplicationUser class. Basically, the whole thing is confusing me because for both of the user types I have different fields. Anyway, I have come up with two possible solutions, however, both of them don't sound like the correct way to achieve my goal.

1) Inherit from ApplicationUser

ApplicationUser.cs

public class ApplicationUser : IdentityUser
{
    [Column(TypeName = "datetime2")]
    public DateTime RegistrationDate { get; set; }

    public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager, string authenticationType)
    {
        var userIdentity = await manager.CreateIdentityAsync(this, authenticationType);
        return userIdentity;
    }
}

Client.cs

public class Client : ApplicationUser
{
}

Driver.cs

public class Driver: ApplicationUser
{
    private ICollection<Country> countriesOfOperation;

    public Driver()
    {
        this.countriesOfOperation = new HashSet<Country>();
    }

    [Column(TypeName = "datetime2")]
    public DateTime DateOfBirth { get; set; }

    [MaxLength(250)]
    public string AboutMe { get; set; }

    public Genders Gender { get; set; }

    public virtual ICollection<Country> CountriesOfOperation
    {
        get { return this.countriesOfOperation; }
        set { this.countriesOfOperation = value; }
    }
}

This means that I have to create register methods into the AccountController like this:

[AllowAnonymous]
[Route("Clients/register")]
public async Task<IHttpActionResult> RegisterClient(ClientRegisterBindingModel model)
{
    var user = new Client()
    {
        UserName = model.Email,
        Email = model.Email,
        RegistrationDate = DateTime.Now
    };

    IdentityResult result = await UserManager.CreateAsync(user, model.Password);

    if (!result.Succeeded)
    {
        return GetErrorResult(result);
    }

    return Ok();
}

Same thing goes for the driver class. Surely, the inheritance reuses stuff like UserName, Email, PasswordHash etc., but it also means that I have to create methods like the register one for every type of user I add. Which makes the account management pain in the ass.

2) Keeping clients and drivers in separate tables by having a field that references an ApplicationUser

public class Client
{
    public string FirstName { get; set; }

    public ApplicationUser Account { get; set; }
}

This seems a bit better, but to access the username of a client I have to do something like clientInstance.Account.UserName, which still doesn't seem elegant enough.

I'm pretty new to the technology and I haven't explored all of its features, so I'm likely missing something fairly obvious. Thanks in advance.

Here is the situation that I am in. I have inherited an ASP.NET web application that our company members use to enter the mileage for their company cars. When they log in, there are first asked to enter the VIN for their car.

The manager who administers the application is adamant that they must type in the entire VIN correctly each time. Apparently this is because they occasionally swap vehicles and then don't tell the Fleet dept about it. There are liability issues.

We told him it isn't practical because nobody is likely to type it in from looking at the physical VIN each time; they are going to store the number in a file and cut and paste. So he wants us to create a little mobile app for that purpose; it's a lot harder to cut and paste with a mobile app.

Then we told him about autocomplete. He was not a happy camper.

Is there any way that we can prevent the autocomplete feature from working? If they don't know about it and it happens to be turned off in their browser, problem solved, but I don't think there is any way of forcing it off, is there? And has anyone else ever had to solve this kind of problem?

I am calling a web service which returns a byte[] of an attachment. I then convert the byte[] to base64 string and return results to the client. i Then want to display this returned string in the browser (IE is necessary). i am getting file not found because i believe IE has URL length limit of a little over 2000. What are my options of displaying the attachment returned? If there's no way to display it, how can i prompt user to save the attachment to a certain location?

Here's what I have:

//Ascx page

  function retrieveAttachmentById() {
        var DTO = { 'p_attachmentID': "123", 'p_itemId': "1" };
        var url = "/_layouts/SharepointWebService/CustomService.asmx/GetAttachmentById";
        $.ajax
        ({
            type: "Post",
            url: url,
            data: JSON.stringify(DTO),
            async: false,
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function add(msg) {
                var url = msg.d;

                // display base64 content.
                //  window.location(url) doesn't work when url is long.                

            },
                    error: function () { }
        });
     }

//CustomService.asmx

[WebMethod]
    public string GetAttachmentById(int p_attachmentID, int p_itemId)
    {
        byte[] fileBuffer = //Call service passing in p_attachmentID and p_itemId
        var url64 = Convert.ToBase64String(fileBuffer); //Succesfull
        return url64;
    }

Any suggestions would be appreciated.

I essentially have the setup described here: http://blogs.msdn.com/b/martinkearn/archive/2015/03/25/securing-and-working-securely-with-web-api.aspx

The trouble is, if a user's roles are modified after receiving a token, the change is not reflected unless the user logs in again and receives a new token.

For example:

  • user is in role "ABC"
  • user logs in, receives a token
  • user uses token to access endpoint decorated with [Authorize(Roles="ABC")] (as expected)
  • administrator takes user out of role "ABC"
  • user can STILL use token to access endpoint decorated with [Authorize(Roles="ABC")] (unexpected)
  • user discards token, logs in again, receives a new token
  • user uses new token to access endpoint decorated with [Authorize(Roles="ABC")] and gets 401 (as expected)

In other words, unless the user requests a new token (logs in again), HttpContext.Current.User.IsInRole("ABC") returns true, even though the AspNetUserRoles table shows that user does NOT have that role.

How can I update (or perhaps invalidate?) the token when changes are made to the AspNetUserRoles table?

I have a simple stored procedure I'm using with my login form. My login form always returns false and I don't know why...

Here is the procedure

CREATE PROCEDURE [dbo].[LoginCheck]
(
    @Email varchar(50),
    @Password varchar(50)
) as
begin
    SET NOCOUNT ON;

    select MemberFirstName
    from Members
    where MemberEmail = @Email
      and MemberPassword = @Password
end
return

And here is my button method:

    protected void ButtonLogIn_Click(object sender, EventArgs e)
    {
        SqlConnection conn = new SqlConnection(@"data source = .\sqlexpress; integrated security = true; database = fitness_database");

        SqlCommand cmd = new SqlCommand();
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "LoginCheck";

        cmd.Connection = conn;

        try
        {
            conn.Open();

            SqlParameter pmUseEmail = new SqlParameter("@Email", TextBoxUsername.Text);
            SqlParameter pmUserPassword = new SqlParameter("@Password", TextBoxUsername.Text);
            cmd.Parameters.Add(pmUseEmail);
            cmd.Parameters.Add(pmUserPassword);

            SqlDataReader dr = cmd.ExecuteReader();

            if (dr.Read())
            {
                // Session["Logged"] = true;
                Label1.Text = "working";
            }
            else
            {
                Label1.Text = "not working";
            }
        }
        catch (Exception ex)
        {
            Label1.Text = ex.Message;
        }
        finally 
        { 
             conn.Close(); 
        }
    }
}

After submitting it always return "not working" Have any idea ?

I have an asp.net web forms project that in it i used old membership and role manager system (i mean Forms Authentication) with custom database tables for users and roles. Now i need to use OAuth to login user with Facebook and Google account. In fact i need to send user name and password to Facebook and receive true or false, after receiving true i will register user with that username and password and then i will call :

FormsAuthentication.RedirectFromLoginPage(UserName,false);

I need something maybe like :

bool result = ValidateUser(FacebookUserName, FacebookPassword);

Can you help me please?