Mvc.Net show many results from web service - asp.net-mvc

I have an mvc 4.0 system that uses other system's web api service. The problem is that sometimes the service returns ~11,000 records, and the web page gets stuck and unable to show all of them.
How can I solve this problem? If the data was stored in my database, I would try to implement paging, but that's not the case.

Related

Calls to ASP.NET WebApi connection issue

Currently I'm working on a ASP.NET MVC webapp which implemented a user dashboard where the user can add various charts to display data. We're using AngularJS for the client side to send the requests for data to a WebAPI solution.
The WebAPI action that returns the data is implemented as async - however, in the action we're querying some rather big Sql Server DB and apply various filters that the clients sets.
In case the user has more charts (10+) and he's "hitting" a big data set the Action on the WebAPI can take a bit of time to process.
My issue is that in Firebug I see all the GET requests being sent by AngularJS to the WebAPI, some of them (2-3) start being processed immediately, but the rest seems to get queued and in Firebug once they are finally processed I see that the Connecting time for them is huge.
Can anyone give me any idea and make understand why WebAPI doesn't seem to respond to all the requests immediately? What am I missing? Are there any settings that I could apply to improve the performance on the WebAPI?
Thank you in advance for any suggestions!
Andrei

the reason not to access directly from xcode to mssql?

I am planning to build an iOS app with using DB(Ms-Sql).
However, people recommends not to access DB from Xcode.
They recommend me to use php or asp for accessing db through a webpage.
I want to know the reason.
Also I am going to use DB only for (view) select line (not insert, update nor delete).
so is it possible to access directly to db for viewing purpose only?
thank you
It's generally bad for an application (mobile, web, any client) to directly have access to any database for security issues. Clients really should not be accessing the database, which is often holding very private/secure data. It opens up vulnerabilities (i.e., sql injection attack).
A set of web services written in php or java or some back-end technology is a more secure, scalable system. These web services can connect to the database and retrieve data. Your iOS application can call the web services and receive the data..for example in the form of XML or JSON.

Http handler for classic ASP application for introducing a layer between client and server

I've a huge classic ASP application where in thousands of users manage their company/business data. Currently this is not multi-user so that application users can create users and authorize them to access certain areas in the system.
I'm thinking of writing a handler which will act as middle man between client and server and go through every request and find out who the user is and whether he is authorized to access the data he is trying to.
For the moment ignore about the part how I'm going to check the authorization and all that stuff. Just want to know whether I can implement a ASP.net handler and use it as middle man for the requests coming for a asp website? I just want to read the url and see what is the page user is trying to access and what are the parameters he is passing in the url the posted data. Is this possible? I read that Asp.net handler cannot be used with asp website and I need to use isapi filter or extensions for that and that can be developed only c/c++.
Can anybody through some light on this and guide me whether I'm in the right direction or not?
Note: To be specific, I cannot modify anything in the existing application because there are hundreds of pages (each page again has couple of different actions, such as posted to the same page again) are there in the system and it is really big mess and we are coming up with a different solution to clear that mess but that takes couple of years to complete, meanwhile to provide the multi-user functionality to the users we are trying to do this. This layer acts like layer where we authorize the user to do certain operation or access a page, nothing more than this.
I've worked with an ASP classic website that runs Javascript on the server side. In IIS we selected JScript as the server-side scripting language and access the session variables and the database simultaneously to check user's access rights when they try to check out various parts of the site. What you're describing is completely do-able. Each page needs to have Javascript in <% %> tags and that identifies the content as server-side code. Be careful with security though!
As for the ASP.NET handler, I also developed an ASP.NET application that I added imported to our site (had to use a .NET thread pool) which could handle Ajax requests. IIS has this option to import ASP.NET applications to your site.
You've got options.

Access Windows Search index using ASP.NET MVC

I'm on a project that is being upgraded from vbscript to ASP.NET MVC. It used Microsoft Index Server to index Word and PDF files on a Windows Server 2003 machine. It simply opened an OleDbConnection using a connection string like "Provider=\"MSIDXS\";Data Source=\"docSearch\";".
After researching a bit, I learned that Index Server is obsolete ("Note Indexing Service is obsolete as of Windows XP. Instead, use Windows Search." - http://msdn.microsoft.com/en-us/library/ms690580) and Windows Search is the successor.
So, in my new MVC app, I'm trying to connect using OleDbConnection with a connection string like "Provider=Search.CollatorDSO;Extended Properties=\"Application=Windows\"".
I have a method that takes in a formatted query and executes the search - here is the query that gets executed using OleDb:
string.Format("SELECT System.FileName FROM SystemIndex WHERE CONTAINS('{0}')", query)
Now, when I call my method in a test class, it works fine (i.e. returns results... myDataReader.HasRows is true). But, when I call the same method from my MVC Controller, it returns no results - myDataReader.HasRows is false - using the same query. My guess is something to do with permissions and IIS not being able to access the index. How can I get IIS to have access to the index? How can I expose the index to a ASP.NET web page? If Index Server is obsolete, and this functionality isn't supported in Windows Search, what am I supposed to use?
I would not change just because it is not supported unless you are having a specific problem with Indexing Service or need a feature from the newer version.
I would get connection string from ISearchQueryHelper
Does the service have the correct permissions? Have you checked the Windows Search 3.0/4.0 SDK?
I see you are on the forum (http://social.msdn.microsoft.com/Forums/en-US/windowsdesktopsearchdevelopment/thread/7b9eead4-d938-42c6-ba2b-2c238a7706f9)
I am not sure Windows Search can really replace Indexing Service for Web sites. For instance, there is only one index called "SystemIndex" which contains everything on the local system. Therefore, how would you limit the results to just a Web site?
I believe you need to use "enterprise search" or "search server", which I have no experience with.
Since the results for both Indexing Service and Windows Search are ADO.NET, the presentation does not change much. The API is different enough that you will need to make many changes. For instance, there is no "scope" in Windows Search. When I changed over my personal "desktop search" application, it took an hour to make the change, but two days to duplicate all the functionality that I had with Indexing Service because of the API changes. I made this change because Windows Search is better when searching for code snippets in my "Code Library"
For standard queries with no regular-expressions or wild-cards or non-standard properties, both perform the same. Indexing Service always retrieves data quicker, but may not perform some queries that are "too expensive". Windows Search can take a long time retrieving the data depending on the query. Typically, these "long queries" are the "too expensive" queries of Indexing Service. "Long queries" can also result from any query that retrieves a property that is not contained in the index.
I am still using Indexing Service for my web sites on Windows Server 2003 and do not plan to make any changes because it is not as easy as I expected and there is no compelling reason to do.
I found my answer here ASP.NET OLEDB code breaks when deployed on IIS7. By impersonating a user that has access to the index.

Securing a mvc view so only the server can access it

I'm building a .Net MVC app, where I'm using one particular view to generate an internal report. I don't want the users of the site to gain access to this page at all.
I've a console app that fires every so often which will scrape some of the details from this page by hitting it's URL.
I don't like the idea of having the URL hanging out there but I'm not sure of another way to go about it.
Thoughts on what might be the best practice way for tackling this?
Edit:
Here's what I ended up doing, created a new WCF Service project in the solution. I also copied basically what was the MVC view page into a new standard web forms page in this project. On top of adding security via the regular .net Authentication methods (eg set only valid windows users can access the page), I can also lock down the vhost to only be accessed by certain IP's.
The best practice would be to expose a wcf service for this, and set up a security model that is different than website.
If you must use MVC the best approach use forms authentication with mvc and set
[Authorize(Roles = "SecureUser")]
On the View.
If the view never needs to be rendered at all except to provide data for the console app, then why not have the console app simply connect to your database to get the data directly instead of going through the web app? You could still do this for the console app even if the view does need to be available for some users, then control access to the view using the Authorization attribute, which could suitably restricted now that an external app need not have access to it.

Resources