dimanche 28 juin 2015

How to make search engines crawl tens of thousands of pages in my website

I have a large amount of items that each item has a page like this site/item_show.aspx?id=The_ID_here there are tens of thousands of items and each day nearly two thousands are added. Furthermore each item has a description in its page so for each item, its page should be crawled by search engines.

My question is with this amount of data described: How can I generate sitemaps or anything like that to make all items visible by google and other search engines?

It is clear that I cannot show all items in the first pages but I can make pages that simply just contains the link of items and provide tens of them each page for just search engine. Would it work or is it anything better to do for making items be indexed by google?

FileUpload in form HTML

I have a Website and in one webpage there is a form, where one of the fields is to upload an image. I have created in my database a column picture of type LONGBINARY. I have read some webpages where they explain how to use <asp:FileUpload ID="FileUpload1" runat="server"/>. But the doubt is that I have an input tag <input id="Submit1" type="submit" value="Put In Store" /> for my form. All the webpages where they explain about FileUpload are using a ASP button, but for my form I need an submit input.

So:

  • What do I do if it says I need a ASP Button but I need a submit input?
  • Where need to be the code of the FileUpload when you click?

My last question about FileUpload(There are the links they gave me).

Can't get dropdown list in mvc5 for a specil title

I'm trying to get better with asp.net mvc5 how ever I've ran into a problem. I've made Gamemodel where you can create games. On my post/create I get a drop down list for the games I've added on my Game model.

I also have my 'Title / Next game' I want a drop-down list on that as-well. But right now it just takes a string, but I would like a drop-down list like for GameId how can I achieve this ?

This is my Post Model

public class Post
{
    [Key]
    public int PostId { get; set; }

    //URL
    [Display(Name = "URL")]
    [StringLength(80)]
    public string Url { get; set; }
    //User
    [Display(Name = "User")]
    public virtual ApplicationUser User { get; set; }

    //Game
    [Display(Name = "Game")]
    public int GameId { get; set; }
    [Display(Name = "Next Game")]
    public string Title { get; set; }
    public virtual Game Game { get; set; }

    //Time
    private DateTime? _date;
    public DateTime? Date
    {
        get
        {
            if (_date == null || _date.ToString() == "1/1/0001 12:00:00 AM")
            {
                return _date = DateTime.Now;
            }
            return _date;
        }
        set
        {
            _date = value;
        }
    }

And this is my Game Model

    public class Game
{
    [Key]
    public int GameId { get; set; }

    //Game
    [Display(Name = "Game")]
    public string Title { get; set; }

    //User
    [Display(Name = "User")]
    public virtual ApplicationUser User { get; set; }
}

Definition of configuration section

I am looking for a good definition of what's called configuration section in Asp.Net as I can't find anything about that anywhere. I am not against any links what can help me shed some light on it.

PopUp is not showing after Excel Download?

I'm writing data into an excel and after completion I'm downloading the excel sheet.

This is my code for downloading

byte[] fileBytes = System.IO.File.ReadAllBytes(excelPath);
        System.Web.HttpContext context = System.Web.HttpContext.Current;
        context.Response.Clear();
        context.Response.ClearHeaders();
        context.Response.ClearContent();
        context.Response.AppendHeader("content-length", fileBytes.Length.ToString());
        context.Response.ContentType = "application/octet-stream ";
        context.Response.AppendHeader("content-disposition", "attachment; filename=" + "ExcelSheet.xls");
        context.Response.BinaryWrite(fileBytes);
        context.ApplicationInstance.CompleteRequest();

After completion of this I'm calling my JavaScript for Popup

    ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true);
    lblLog.Text = "Successfully Downloaded";

But it is not showing the popup. If I remove the code for download it is working perfectly.What should I do to downlod and get poup.

Ninject doesn't make implementation of interface

I'm unable to make Ninject work in my ASP.NET MVC 5 project.
It doesn't want to make the concrete object connected to the interface and I'm out of ideas what could fix this.

My project has an interface IQuizRepository in Domain.Abstract which consists of only ICollection<Quiz> Quizes { get; }
The implementation is QuizRepository in Domain.Concrete and looks like this:

public class QuizRepository : IQuizRepository
{
    public ICollection<Quiz> Quizes { get; private set; }

    public QuizRepository()
    {
        List<Quiz> quizes = new List<Quiz>();
        // adding some Quiz objects to the list
        Quizes = quizes;
    }
}

The controller is Website.Controllers.HomeController.cs which simply tests if Ninject works and looks like this:

public ActionResult Index(IQuizRepository quiz)
{
    ViewBag.test = quiz.Quizes.First().Id;
    return View();
}

NinjectWebCommon which is in Website.App_Start is equal to the default generated one except the RegisterServices method:

public static class NinjectWebCommon 
    {
        private static readonly Bootstrapper bootstrapper = new Bootstrapper();

        public static void Start() 
        {
            DynamicModuleUtility.RegisterModule(typeof(OnePerRequestHttpModule));
            DynamicModuleUtility.RegisterModule(typeof(NinjectHttpModule));
            bootstrapper.Initialize(CreateKernel);
        }

        public static void Stop()
        {
            bootstrapper.ShutDown();
        }

        private static IKernel CreateKernel()
        {
            var kernel = new StandardKernel();
            try
            {
                kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel);
                kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>();

                RegisterServices(kernel);
                return kernel;
            }
            catch
            {
                kernel.Dispose();
                throw;
            }
        }

        private static void RegisterServices(IKernel kernel)
        {
            kernel.Bind<Domain.Abstract.IQuizRepository>().To<Domain.Concrete.QuizRepository>();
        }        
    }

It still fails to make the implementation of IQuizRepository.
I think I have all the NuGet packages installed that are required:

Ninject v3.2.0.0
Ninject.MVC5 v3.2.1.0
Ninject.Web.Common v3.2.0.0
Ninject.Web.Common.WebHost v3.2.0.0

The stacktrace (sadly partly in Dutch since I can't get the error messages to show in English):

[MissingMethodException: Kan geen exemplaar van een interface maken.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +113
   System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +232
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +83
   System.Activator.CreateInstance(Type type) +66
   System.Web.Mvc.DefaultModelBinder.CreateModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType) +197

[MissingMethodException: Kan geen exemplaar van een interface maken. Object type 'Domain.Abstract.IQuizRepository'.]
   System.Web.Mvc.DefaultModelBinder.CreateModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType) +233
   System.Web.Mvc.DefaultModelBinder.BindComplexModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +532
   System.Web.Mvc.DefaultModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +330
   System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) +331
   System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +105
   System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__19(AsyncCallback asyncCallback, Object asyncState) +743
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +14
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
   System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state) +343
   System.Web.Mvc.Controller.<BeginExecuteCore>b__1c(AsyncCallback asyncCallback, Object asyncState, ExecuteCoreState innerState) +25
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +30
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
   System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state) +465
   System.Web.Mvc.Controller.<BeginExecute>b__14(AsyncCallback asyncCallback, Object callbackState, Controller controller) +18
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +20
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
   System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +374
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +16
   System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__4(AsyncCallback asyncCallback, Object asyncState, ProcessRequestState innerState) +52
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +30
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +384
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +48
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +301
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

unable to convert .htaccess to web.config

For this pc of code

<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>

i am using

<rule name="rule 1A" stopProcessing="true">
<match url="."  />
<action type="Rewrite" url="/index.php"  />
</rule>

but not work... why ?